Learn R Programming

amadeus

amadeus is a mechanism for data, environments, and user setup for common environmental and climate health datasets in R. amadeus has been developed to improve access to and utility with large scale, publicly available environmental data in R.

See the peer-reviewed publication, Amadeus: Accessing and analyzing large scale environmental data in R, for full description and details.

Cite amadeus as:

Manware, M., Song, I., Marques, E. S., Kassien, M. A., Clark, L. P., & Messier, K. P. (2025). Amadeus: Accessing and analyzing large scale environmental data in R. Environmental Modelling & Software, 186, 106352.

Installation

amadeus can be installed from CRAN with install.packages or from GitHub with pak.

install.packages("amadeus")
pak::pak("NIEHS/amadeus")

Download

download_data accesses and downloads raw geospatial data from a variety of open source data repositories. The function is a wrapper that calls source-specific download functions, each of which account for the source's unique combination of URL, file naming conventions, and data types. Download functions cover the following sources:

Data SourceFile TypeData GenreSpatial ExtentFunction Suffix
Climatology Lab TerraClimatenetCDFMeteorologyGlobal_terraclimate
Climatology Lab GridMetnetCDFClimateWaterContiguous United States_gridmet
Köppen-Geiger Climate ClassificationGeoTIFFClimate ClassificationGlobal_koppen_geiger
MRLC[^1] Consortium National Land Cover Database (NLCD)GeoTIFFLand UseUnited States_nlcd
NASA[^2] Moderate Resolution Imaging Spectroradiometer (MODIS)HDFAtmosphereMeteorologyLand UseSatelliteGlobal_modis
NASA Modern-Era Retrospective analysis for Research and Applications, Version 2 (MERRA-2)netCDFAtmosphereMeteorologyGlobal_merra2
NASA SEDAC[^3] UN WPP-Adjusted Population DensityGeoTIFFnetCDFPopulationGlobal_population
NASA SEDAC Global Roads Open Access Data SetShapefileGeodatabaseRoadwaysGlobal_groads
NASA Goddard Earth Observing System Composition Forcasting (GEOS-CF)netCDFAtmosphereMeteorologyGlobal_geos
NOAA Hazard Mapping System Fire and Smoke ProductShapefileKMLWildfire SmokeNorth America_hms
NOAA NCEP[^4] North American Regional Reanalysis (NARR)netCDFAtmosphereMeteorologyNorth America_narr
US EPA[^5] Air Data Pre-Generated Data FilesCSVAir PollutionUnited States_aqs
US EPA EcoregionsShapefileClimate RegionsNorth America_ecoregions
US EPA National Emissions Inventory (NEI)CSVEmissionsUnited States_nei
US EPA Toxic Release Inventory (TRI) ProgramCSVChemicalsPollutionUnited States_tri
USGS[^6] Global Multi-resolution Terrain Elevation Data (GMTED2010)ESRI ASCII GridElevationGlobal_gmted

See the "download_data" vignette for a detailed description of source-specific download functions.

Example use of download_data using NOAA NCEP North American Regional Reanalysis's (NARR) "weasd" (Daily Accumulated Snow at Surface) variable.

directory <- "/  EXAMPLE  /  FILE  /  PATH  /"
download_data(
  dataset_name = "narr",
  year = 2022,
  variable = "weasd",
  directory_to_save = directory,
  acknowledgement = TRUE,
  download = TRUE,
  hash = TRUE
)
Downloading requested files...
Requested files have been downloaded.
[1] "5655d4281b76f4d4d5bee234c2938f720cfec879"
list.files(file.path(directory, "weasd"))
[1] "weasd.2022.nc"

Process

process_covariates imports and cleans raw geospatial data (downloaded with download_data), and returns a single SpatRaster or SpatVector into the user's R environment. process_covariates "cleans" the data by defining interpretable layer names, ensuring a coordinate reference system is present, and managing `timedata (if applicable).

To avoid errors when using process_covariates, do not edit the raw downloaded data files. Passing user-generated or edited data into process_covariates may result in errors as the underlying functions are adapted to each sources' raw data file type.

Example use of process_covariates using the downloaded "weasd" data.

weasd_process <- process_covariates(
  covariate = "narr",
  date = c("2022-01-01", "2022-01-05"),
  variable = "weasd",
  path = file.path(directory, "weasd"),
  extent = NULL
)
Detected monolevel data...
Cleaning weasd data for 2022...
Returning daily weasd data from 2022-01-01 to 2022-01-05.
weasd_process
class       : SpatRaster
dimensions  : 277, 349, 5  (nrow, ncol, nlyr)
resolution  : 32462.99, 32463  (x, y)
extent      : -16231.49, 11313351, -16231.5, 8976020  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=lcc +lat_0=50 +lon_0=-107 +lat_1=50 +lat_2=50 +x_0=5632642.22547 +y_0=4612545.65137 +datum=WGS84 +units=m +no_defs
source      : weasd.2022.nc:weasd
varname     : weasd (Daily Accumulated Snow at Surface)
names       : weasd_20220101, weasd_20220102, weasd_20220103, weasd_20220104, weasd_20220105
unit        :         kg/m^2,         kg/m^2,         kg/m^2,         kg/m^2,         kg/m^2
time        : 2022-01-01 to 2022-01-05 UTC

Calculate Covariates

calculate_covariates stems from the beethoven project's need for various types of data extracted at precise locations. calculate_covariates, therefore, extracts data from the "cleaned" SpatRaster or SpatVector object at user defined locations. Users can choose to buffer the locations. The function returns a data.frame, sf, or SpatVector with data extracted at all locations for each layer or row in the SpatRaster or SpatVector object, respectively.

Example of calculate_covariates using processed "weasd" data.

locs <- data.frame(id = "001", lon = -78.8277, lat = 35.95013)
weasd_covar <- calculate_covariates(
  covariate = "narr",
  from = weasd_process,
  locs = locs,
  locs_id = "id",
  radius = 0,
  geom = "sf"
)
Detected `data.frame` extraction locations...
Calculating weasd covariates for 2022-01-01...
Calculating weasd covariates for 2022-01-02...
Calculating weasd covariates for 2022-01-03...
Calculating weasd covariates for 2022-01-04...
Calculating weasd covariates for 2022-01-05...
Returning extracted covariates.
weasd_covar
Simple feature collection with 5 features and 3 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 8184606 ymin: 3523283 xmax: 8184606 ymax: 3523283
Projected CRS: unnamed
   id       time     weasd_0                geometry
1 001 2022-01-01 0.000000000 POINT (8184606 3523283)
2 001 2022-01-02 0.000000000 POINT (8184606 3523283)
3 001 2022-01-03 0.000000000 POINT (8184606 3523283)
4 001 2022-01-04 0.000000000 POINT (8184606 3523283)
5 001 2022-01-05 0.001953125 POINT (8184606 3523283)

Connecting Health Outcomes Research Data Systems

The amadeus package has been developed as part of the National Institute of Environmental Health Science's (NIEHS) Connecting Health Outcomes Research Data Systems (CHORDS) program. CHORDS aims to "build and strengthen data infrastructure for patient-centered outcomes research on environment and health" by providing curated data, analysis tools, and educational resources.

Additional Resources

The following R packages can also be used to access climate and weather data in R, but each differs from amadeus in the data sources covered or type of functionality provided.

PackageSource
dataRetrievalUSGS Hydrological Data and EPA Water Quality Data
daymetrDaymet
ecmwfrECMWF Reanalysis v5 (ERA5)
RClimChange[^7]NASA Earth Exchange Global Daily Downscaled Projections (NEX-GDDP-CMIP6)
rNOMADSNOAA Operational Model Archive and Distribution System
sen2r[^8]Sentinel-2

Contribution

To add or edit functionality for new data sources or datasets, open a Pull request into the main branch with a detailed description of the proposed changes. Pull requests must pass all status checks, and then will be approved or rejected by amadeus's authors.

Utilize Issues to notify the authors of bugs, questions, or recommendations. Identify each issue with the appropriate label to help ensure a timely response.

[^1]: Multi-Resolution Land Characteristics [^2]: National Aeronautics and Space Administration [^3]: Socioeconomic Data and Applications Center [^4]: National Centers for Environmental Prediction [^5]: United States Environmental Protection Agency [^6]: United States Geological Survey [^7]: Last updated more than two years ago. [^8]: Archived; no longer maintained.

Copy Link

Version

Install

install.packages('amadeus')

Monthly Downloads

345

Version

1.2.4.9

License

MIT + file LICENSE

Maintainer

Kyle Messier

Last Published

August 24th, 2025

Functions in amadeus (1.2.4.9)

calculate_modis

Calculate MODIS product covariates in multiple CPU threads
calculate_merra2

Calculate meteorological and atmospheric covariates
calculate_hms

Calculate wildfire smoke covariates
calculate_nei

Calculate road emissions covariates
calculate_gridmet

Calculate gridMET covariates
calculate_nlcd

Calculate land cover covariates
check_destfile

Check if destination file exists or is 0 bytes.
check_for_null_parameters

Check parameters
calculate_terraclimate

Calculate TerraClimate covariates
calculate_tri

Calculate toxic release covariates
calculate_lagged

Calculate temporally lagged covariates
check_mysftime

Check sftime object
check_url_status

Check HTTP status
calculate_ecoregion

Calculate ecoregions covariates
calculate_geos

Calculate atmospheric composition covariates
download_aqs

Download air quality data
cov

Calculate code coverage of the beethoven package with the container.sif container.
calculate_temporal_dummies

Calculate temporal dummy covariates
calculate_population

Calculate population density covariates
check_urls

Implement check_url_status
collapse_nlcd

Collapse listed NLCD values while filling in NA for sites outside data.
download_gmted

Download elevation data
download_gridmet

Download gridMET data
download_data

Download raw data wrapper function
calculate_modis_daily

A single-date MODIS worker
calculate_narr

Calculate meteorological covariates
download_ecoregion

Download ecoregion data
download_edgar

Download EDGAR Emissions Data
download_cropscape

Download CropScape data
check_mysf

Check sf object
download_hms

Download wildfire smoke data
download_merra2

Download meteorological and atmospheric data
check_geom

Check that geom value is one of FALSE, "sf", or "terra"
download_hash

Create hash of downloaded files.
download_narr

Download meteorological data
download_modis

Download MODIS product files
extract_urls

Extract download URLs
dt_as_mysftime

Convert a data.table to an sftime
download_groads

Download roads data
download_koppen_geiger

Download climate classification data
download_nei

Download road emissions data
download_sanitize_path

Sanitize directory
download_nlcd

Download land cover data
download_huc

Download National Hydrography Dataset (NHD) data
process_blackmarble

Assign VIIRS Black Marble products corner coordinates to retrieve a merged raster
download_setup_dir

Setup directory
download_tri

Download toxic release data
process_blackmarble_corners

Process Black Marble corners
process_covariates

Process raw data wrapper function
download_prism

Download PRISM data
download_remove_zips

Remove zip files
download_remove_command

Remove download commands
process_gmted

Process elevation data
process_geos

Process atmospheric composition data
process_conformity

Check input assumptions
process_groads

Process roads data
download_unzip

Unzip zip files
process_collection

Process GEOS-CF and MERRA2 collection codes
download_epa_certificate

Check EPA certificate
process_gridmet_codes

Process gridMET variable codes
process_merra2

Process meteorological and atmospheric data
process_locs_vector

Process locations as SpatVector
process_cropscape

Process CropScape data
process_modis_sds

Process MODIS sub-datasets
process_flatten_sds

Process MODIS layers
process_ecoregion

Process ecoregion data
download_terraclimate

Download TerraClimate data
download_geos

Download atmospheric composition data
process_aqs

Process U.S. EPA AQS daily CSV data
generate_time_sequence

Generate time sequence
process_population

Process population density data
download_sink

Sink download commands
download_run

Run download commands
process_modis_swath

Mosaic MODIS swaths
narr_variable

Sort NOAA NARR variables
generate_date_sequence

Generate date sequence
process_prism

Process PRISM data
read_commands

Import download commands
process_variable_codes

Filter gridMET and terraClimate variable names and variable codes
process_sedac_codes

Process population resolution code
process_merra2_time

Process MERRA2 time steps
process_hms

Process wildfire smoke data
process_modis_merge

Process MODIS .hdf files
process_modis_warp

Warp MODIS swath data into rectilinear grid raster
sum_edc

Calculate isotropic Sum of Exponentially Decaying Contributions (SEDC) covariates
sf_as_mysftime

Convert an sf to an sftime
process_terraclimate

Process TerraClimate data
sftime_as_spatraster

Convert an sftime to a SpatRaster
rename_time

Rename $time
test

Run all tests within a single file from tests/testthat/ directory with the container.sif container.
process_terraclimate_codes

Process terraClimate variable codes
test_download_functions

Download unit tests
process_tri

Process toxic release data
interactive

Open interactive session with container.sif container.
sftime_as_spatrds

Convert an sftime to a SpatRasterDataset
process_huc

Retrieve Hydrologic Unit Code (HUC) data
download_population

Download population density data
process_narr

Process meteorological data
sftime_as_spatvector

Convert an sftime to a SpatVector
download_permit

Check data download acknowledgement
spatraster_as_sftime

Convert a SpatRaster to an sftime
is_date_proper

Check date format
sftime_as_sf

Convert an sftime to an sf
sftime_as_mysftime

Convert an sftime to a mysftime
process_gmted_codes

Process elevation statistic and resolution codes
process_gridmet

Process gridMET data
process_koppen_geiger

Process climate classification data
process_nlcd

Process land cover data
process_nei

Process road emissions data
spatrds_as_sftime

Convert a SpatRasterDataset to an sftime
spatvector_as_sftime

Convert a SpatVector to an sftime
process_locs_radius

Process locations buffer
apply_extent

Apply extent to the processed data
calc_time

Prepare time values
calc_return_locs

Prepare covariates for return
calc_worker

Perform covariate extraction
calc_prepare_locs

Prepare extraction locations
calc_message

Send progress messages
calc_setcolumns

Set column names
calculate_covariates

Calculate covariates wrapper function
as_mysftime

Create an sftime object
calculate_groads

Calculate roads covariates
calculate_koppen_geiger

Calculate climate classification covariates
calculate_gmted

Calculate elevation covariates
calc_check_time

Check time values