View source: R/get_stationid.R
| get_stationid | R Documentation |
Queries the NOAA Climate Data Online (CDO) API to retrieve station identifiers associated with a specified dataset, location, and date range.
get_stationid(
noaa_token,
datasetid,
locationid = NULL,
startdate,
enddate,
n_results = Inf
)
noaa_token |
A character string. Your NOAA API token used for authentication. You can request a token at https://www.ncdc.noaa.gov/cdo-web/token. |
datasetid |
A valid dataset ID (e.g., "GHCND", "GSOM", etc.). Use |
locationid |
Optional. A valid location ID (e.g., "FIPS:37", "CITY:US390029"). If |
startdate |
Start date (YYYY-MM-DD) for station data coverage. |
enddate |
End date (YYYY-MM-DD) for station data coverage. |
n_results |
Maximum number of station results to retrieve. Defaults to |
A data frame containing metadata for the matching NOAA stations.
if (nzchar(Sys.getenv("NOAA_TOKEN"))) {
# Retrieve your NOAA API token from environment
noaa_token <- Sys.getenv("NOAA_TOKEN")
# Get stations for the GHCND dataset in Texas between 2020-01-01 and 2020-12-31
stations <- get_stationid(
noaa_token = noaa_token,
datasetid = "GHCND",
locationid = "FIPS:48",
startdate = "2020-01-01",
enddate = "2020-12-31"
)
head(stations)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.