nasa

If this project helped, consider supporting it:

Buy Me a Coffee

Access National Aeronautics and Space Administration (NASA) Open APIs for Space and Earth Data.

The nasa package provides functions to access and download data from various NASA APIs, including:

All retrieved data is returned in cleaned, tidy data frames suitable for analysis or visualization.

Install

Install from CRAN:

install.packages("noaa")

Install from the rOpenGov universe:

# Enable repository from ropengov
options(repos = c(
  ropengov = 'https://ropengov.r-universe.dev',
  CRAN = 'https://cloud.r-project.org'))
  
# Download and install noaa
install.packages("noaa")

API Use

Most functions in this package can be run using the default DEMO_KEY. However, because the DEMO_KEY is publicly shared and subject to rate limits, it is recommended to request your own API key from NASA by visiting https://api.nasa.gov/.

Installation

Functions

get_apod_metadata(start_date, end_date, api_key = "DEMO_KEY", folder_name = NULL)

get_mars_rover_photos_and_metadata(rover, earth_date, api_key = "DEMO_KEY", folder_name = NULL)

get_earthdata(keyword, n_results, start_date = NULL, end_date = NULL)

Example usage

Load the library

library(nasa)

Get Astronomy Picture of the Day metadata

apod_data <- get_apod_metadata(
  start_date = "2024-04-01",
  end_date = "2024-04-02",
  api_key = "DEMO_KEY")

Retrieve Mars Rover Photos metadata

mars_data <- get_mars_rover_photos_and_metadata(
  rover = "curiosity",
  earth_date = "2020-02-01",
  api_key = "DEMO_KEY")

Search Earthdata for "sea surface temperature" (or any keyword or phrase)

earthdata_results <- get_earthdata(
  keyword = "sea surface temperature",
  n_results = 10)