| Title: | Access National Aeronautics and Space Administration (NASA) Open APIs for Space and Earth Data |
|---|---|
| Description: | Provides functions to access and download data from various NASA APIs, including: Astronomy Picture of the Day (APOD), Mars Rover Photos, Earth Polychromatic Imaging Camera (EPIC), Near Earth Object Web Service (NeoWs), Earth Observatory Natural Event Tracker (EONET), and NASA Earthdata CMR Search. Most endpoints require a NASA API key for access. Data is retrieved, cleaned for analysis, and returned in a dataframe-friendly format. |
| Authors: | Steph Buongiorno [aut, cre] |
| Maintainer: | Steph Buongiorno <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-06-07 07:15:25 UTC |
| Source: | https://github.com/rOpenGov/noaa |
Queries the NOAA Climate Data Online (CDO) API to retrieve climate data for a given dataset, station or location, and date range. Supports automatic pagination to collect large datasets.
get_climate_data( noaa_token, datasetid, stationid = NULL, locationid = NULL, startdate, enddate, n_results = Inf )get_climate_data( noaa_token, datasetid, stationid = NULL, 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", "GSOY"). Use |
stationid |
Optional. A NOAA station ID (e.g., "GHCND:USW00094728"). Required for most station-based datasets. |
locationid |
Optional. A NOAA location ID (e.g., "FIPS:37", "CITY:US390029"). Used for location-based datasets. |
startdate |
Start date (YYYY-MM-DD) for the query range. |
enddate |
End date (YYYY-MM-DD) for the query range. |
n_results |
Maximum number of results to retrieve. Defaults to |
A data frame of climate data observations returned by the NOAA API.
if (nzchar(Sys.getenv("NOAA_TOKEN"))) { # Set your NOAA token noaa_token <- Sys.getenv("NOAA_TOKEN") # Example request: Daily summaries from Central Park, NY (GHCND:USW00094728) data <- get_climate_data( noaa_token = noaa_token, datasetid = "GHCND", stationid = "USW00094728", startdate = "2020-01-01", enddate = "2020-01-31" ) head(data) }if (nzchar(Sys.getenv("NOAA_TOKEN"))) { # Set your NOAA token noaa_token <- Sys.getenv("NOAA_TOKEN") # Example request: Daily summaries from Central Park, NY (GHCND:USW00094728) data <- get_climate_data( noaa_token = noaa_token, datasetid = "GHCND", stationid = "USW00094728", startdate = "2020-01-01", enddate = "2020-01-31" ) head(data) }
Queries the NOAA Climate Data Online (CDO) API to retrieve location identifiers for a specified category (e.g., state, city, county).
get_locationid(noaa_token, category_id, n_results = Inf)get_locationid(noaa_token, category_id, 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. |
category_id |
A valid location category ID. Options: "ST", "CITY", "COUNTY", "ZIP", "CLIM_REG", "HYDROL_REG", "FIPS". |
n_results |
Maximum number of results to retrieve. Defaults to Inf (all results). |
A data frame of location IDs matching the given category.
if (nzchar(Sys.getenv("NOAA_TOKEN"))) { # Retrieve token from environment variable noaa_token <- Sys.getenv("NOAA_TOKEN") # Get all U.S. state-level location IDs using category "FIPS" locations <- get_locationid(noaa_token = noaa_token, category_id = "FIPS") head(locations) }if (nzchar(Sys.getenv("NOAA_TOKEN"))) { # Retrieve token from environment variable noaa_token <- Sys.getenv("NOAA_TOKEN") # Get all U.S. state-level location IDs using category "FIPS" locations <- get_locationid(noaa_token = noaa_token, category_id = "FIPS") head(locations) }
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 )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) }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) }