The USGS Water Data STAC API provides access to USGS water data using the SpatioTemporal Asset Catalog (STAC) family of standards. These APIs will provide access to a wide array of USGS water data stored in native formats. That means this API will provide you with links to where the data you're interested in is stored, rather than providing you the data directly as a result of your query.
Arguments
- ...
filter arguments to filter on
- collections
Could be "daily", "continuous", "ratings".
- bbox
Only features that have a geometry that intersects the bounding box are selected.The bounding box is provided as four or six numbers, depending on whether the coordinate reference system includes a vertical axis (height or depth).
- limit
description
- custom_filter
Custom STAC filter. Default is NA. Uses CQL2 formatting.
Examples
# \donttest{
monitoring_location_id <- c("USGS-01435000", "USGS-05406360")
features_2_sites <- search_stac(
monitoring_location_id = monitoring_location_id,
collections = c("daily", "continuous"))
#> Requesting:
#> https://api.waterdata.usgs.gov/stac/v0/search?collections=daily%2Ccontinuous&filter=monitoring_location_id%20IN%20%28%27USGS-01435000%27%2C%20%27USGS-05406360%27%29%20OR%20&filter-lang=cql2-text&limit=50000&f=json&lang=en-US
#> Remaining requests this hour:1301
features_county <- search_stac(
county_name = "Dane County",
state_name = "Wisconsin",
site_type = "Stream",
#start_datetime = c(NA, "2000-01-01"), # starts before 2000
end_datetime = c("2026-01-01", NA), # ends after 2026
collections = "daily"
)
#> Requesting:
#> https://api.waterdata.usgs.gov/stac/v0/search?collections=daily&end_datetime=2026-01-01T00%3A00%3A00Z%2F..&filter=county_name%20%3D%20%27Dane%20County%27%20AND%20state_name%20%3D%20%27Wisconsin%27%20AND%20site_type%20%3D%20%27Stream%27%20OR%20&filter-lang=cql2-text&limit=50000&f=json&lang=en-US
#> Remaining requests this hour:1301
# HUCs return all HUCs that start with the entered value
features_huc <- search_stac(
hydrologic_unit_code = "07090002"
)
#> Requesting:
#> https://api.waterdata.usgs.gov/stac/v0/search?collections=daily%2Ccontinuous%2Cratings&filter=hydrologic_unit_code%20LIKE%20%2707090002%25%27&filter-lang=cql2-text&limit=50000&f=json&lang=en-US
#> Remaining requests this hour:1302
unlist(unique(sapply(features_huc, function(x)
x[["properties"]]["hydrologic_unit_code"])))
#> [1] "070900020604" "070900020702" "070900020401" "070900020901" "070900020603"
#> [6] "070900020701" "070900020902" "070900020602" "070900021406" "070900021201"
#> [11] "070900020703" "070900021501" "070900021502" "070900021303" "070900020601"
#> [16] "070900020101" "070900020301" "070900021006" "070900021402" "070900021003"
#> [21] "070900020303" "070900020903" "070900020504" "070900021001" "070900021403"
#> [26] "070900020202" "070900021407" "070900021401" "070900020905" "070900020803"
#> [31] "070900020802" "070900020305" "070900020801" "070900020405" "070900020404"
#> [36] "070900020503" "070900020203" "070900020501"
features_huc2 <- search_stac(
hydrologic_unit_code = c("0709000203", "0709000204")
)
#> Requesting:
#> https://api.waterdata.usgs.gov/stac/v0/search?collections=daily%2Ccontinuous%2Cratings&filter=hydrologic_unit_code%20LIKE%20%270709000203%25%27%20OR%20hydrologic_unit_code%20LIKE%20%270709000204%25%27&filter-lang=cql2-text&limit=50000&f=json&lang=en-US
#> Remaining requests this hour:1302
unlist(unique(sapply(features_huc2, function(x)
x[["properties"]]["hydrologic_unit_code"])))
#> [1] "070900020401" "070900020301" "070900020303" "070900020305" "070900020405"
#> [6] "070900020404"
# Paging example:
features_OH <- search_stac(
state_name = "Ohio",
limit = 500
)
#> Requesting:
#> https://api.waterdata.usgs.gov/stac/v0/search?collections=daily%2Ccontinuous%2Cratings&filter=state_name%20%3D%20%27Ohio%27%20OR%20&filter-lang=cql2-text&limit=500&f=json&lang=en-US
#> Remaining requests this hour:1301
#> Remaining requests this hour:1301
#> Remaining requests this hour:1299
#> Remaining requests this hour:1297
# }
