Skip to content

Commit

Permalink
Merge pull request #108 from NIEHS/mm-cran-0723
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
mitchellmanware authored Jul 25, 2024
2 parents d02af02 + f596df8 commit b63e8ea
Show file tree
Hide file tree
Showing 28 changed files with 303 additions and 273 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}
#- {os: macos-13-xlarge, r: 'release'}
#- {os: windows-latest, r: 'release'}
- {os: macos-13-xlarge, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Package: amadeus
Title: AMADEUS: A Machine for Data, Environments, and User Setup for common environmental and climate health datasets
Title: A Machine for Data, Environments, and User Setup for Common Environmental and Climate Health Datasets
Version: 0.3.0
Authors@R: c(
person("Mitchell", "Manware", role = c("aut", "ctb"), comment = c(ORCID = "0009-0003-6440-6106")),
person("Insang", "Song", role = c("aut", "ctb"), comment = c(ORCID = "0000-0001-8732-3256")),
person("Eva", "Marques", role = c("aut", "ctb"), comment = c(ORCID = "0000-0001-9817-6546")),
person("Mariana", "Alifa Kassien", role = c("aut", "ctb"), comment = c(ORCID = "0000-0003-2295-406X")),
person("Kyle", "Messier", , "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9508-9623"))
person("Kyle", "Messier", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0001-9508-9623"))
)
Description: A Mechanism/Machine for Data, Environments, and User Setup package for health and climate research. It is fully tested, versioned, and open source and open access.
Maintainer: Kyle Messier <[email protected]>
Description: amadeus is designed to faciliate access to and utiltiy with large scale, publicly available environmental data in R. The package contains funtions for downloading (download_data()) raw data files from web URLs, processing (process_covariates()) the raw data files into interpretable spatial objects, and extracting values (calc_covariates()) from the spatial data objects at point and polygon locations. These functions call a series of source-specific functions which are tailored to each data sources/datasets particular URL structure, data format, and spatio-temporal resolution. amadeus functions are tested, versioned, and open source and open access.
Depends: R (>= 4.1.0)
Imports: dplyr, sf, sftime, stats, terra, methods, data.table, httr, rvest, exactextractr, utils, stringi, testthat (>= 3.0.0), parallelly, stars, future, future.apply, tidyr, rlang, rstac, nhdplusTools, archive, collapse, Rdpack
Suggests: covr, withr, knitr, rmarkdown, lwgeom, FNN, doRNG
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(apply_extent)
export(as_mysftime)
export(calc_check_time)
export(calc_covariates)
Expand Down Expand Up @@ -179,6 +180,7 @@ importFrom(stars,read_stars)
importFrom(stars,st_mosaic)
importFrom(stars,st_warp)
importFrom(stats,aggregate)
importFrom(stats,na.omit)
importFrom(stats,setNames)
importFrom(stringi,stri_pad)
importFrom(terra,aggregate)
Expand Down
38 changes: 19 additions & 19 deletions R/calculate_covariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
#' function.
#' @note `covariate` argument value is converted to lowercase.
#' @seealso
#' - [`calc_modis_par`]: `"modis"`, `"MODIS"`
#' - [`calc_koppen_geiger`]: `"koppen-geiger"`, `"koeppen-geiger"`, `"koppen"`
#' - [`calc_ecoregion`]: `"ecoregion"`, `"ecoregions"`
#' - [`calc_temporal_dummies`]: `"dummies"`
#' - [`calc_hms`]: `"hms"`, `"smoke"`
#' - [`calc_gmted`]: `"gmted"`
#' - [`calc_narr`]: `"narr"`
#' - [`calc_geos`]: `"geos"`, `"geos_cf"`
#' - [`calc_sedac_population`]: `"population"`, `"sedac_population"`
#' - [`calc_sedac_groads`]: `"roads"`, `"groads"`, `"sedac_groads"`
#' - [`calc_nlcd`]: `"nlcd"`
#' - [`calc_tri`]: `"tri"`
#' - [`calc_nei`]: `"nei"`
#' - [`calc_merra2`]: `"merra"`, `"MERRA"`, `"merra2"`, `"MERRA2"`
#' - [`calc_gridmet`]: `"gridMET"`, `"gridmet"`
#' - [`calc_terraclimate`]: `"terraclimate"`, `"TerraClimate"`
#' * \code{\link{calc_modis_par}}: "modis", "MODIS"
#' * \code{\link{calc_koppen_geiger}}: "koppen-geiger", "koeppen-geiger", "koppen"
#' * \code{\link{calc_ecoregion}}: "ecoregion", "ecoregions"
#' * \code{\link{calc_temporal_dummies}}: "dummies", "Dummies"
#' * \code{\link{calc_hms}}: "hms", "smoke", "HMS"
#' * \code{\link{calc_gmted}}: "gmted", "GMTED"
#' * \code{\link{calc_narr}}: "narr", "NARR"
#' * \code{\link{calc_geos}}: "geos", "geos_cf", "GEOS"
#' * \code{\link{calc_sedac_population}}: "population", "sedac_population"
#' * \code{\link{calc_sedac_groads}}: "roads", "groads", "sedac_groads"
#' * \code{\link{calc_nlcd}}: "nlcd", "NLCD"
#' * \code{\link{calc_tri}}: "tri", "TRI"
#' * \code{\link{calc_nei}}: "nei", "NEI"
#' * \code{\link{calc_merra2}}: "merra", "MERRA", "merra2", "MERRA2"
#' * \code{\link{calc_gridmet}}: "gridMET", "gridmet"
#' * \code{\link{calc_terraclimate}}: "terraclimate", "TerraClimate"
#' @return Calculated covariates as a data.frame or SpatVector object
#' @author Insang Song
#' @examples
Expand Down Expand Up @@ -1128,15 +1128,15 @@ calc_temporal_dummies <-
#' - `attr(result, "sedc_threshold")``: the threshold distance
#' at which emission source points are excluded beyond that
#' @note The function is originally from
#' [chopin](https://github.com/kyle-messier/chopin)
#' [chopin](https://github.com/NIEHS/chopin)
#' Distance calculation is done with terra functions internally.
#' Thus, the function internally converts sf objects in
#' \code{point_*} arguments to terra.
#' The threshold should be carefully chosen by users.
#' @author Insang Song
#' @references
#' * [Messier KP, Akita Y, & Serre ML. (2012). Integrating Address Geocoding, Land Use Regression, and Spatiotemporal Geostatistical Estimation for Groundwater Tetrachloroethylene. _Environmental Science & Technology_ 46(5), 2772-2780.](https://dx.doi.org/10.1021/es203152a)
#' * Wiesner C. (n.d.). [Euclidean Sum of Exponentially Decaying Contributions Tutorial](https://mserre.sph.unc.edu/BMElab_web/SEDCtutorial/index.html)
#' \insertRef{messier2012integrating}{amadeus}
#' \insertRef{web_sedctutorial}{amadeus}
#' @examples
#' library(terra)
#' library(sf)
Expand Down
2 changes: 2 additions & 0 deletions R/calculate_covariates_auxiliary.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#' coordinate location.
#' @keywords internal
#' @importFrom stringi stri_pad
#' @return a data.frame or SpatVector object (depending on `from`)
#' @export
calc_setcolumns <- function(
from,
Expand Down Expand Up @@ -507,6 +508,7 @@ calc_worker <- function(
#' @importFrom terra vect
#' @keywords auxiliary
#' @author Mitchell Manware
#' @return a data.frame or SpatVector object (depending on `geom` paramter)
#' @export
# nolint start
calc_return_locs <- function(
Expand Down
56 changes: 28 additions & 28 deletions R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#' * \code{\link{download_nei}}: `"nei"`, `"NEI"`
#' * \code{\link{download_gridmet}}: `"gridMET"`, `"gridmet"`
#' * \code{\link{download_terraclimate}}: `"TerraClimate"`, `"terraclimate"`
#' @returns NULL
#' @return NULL
#' @examples
#' \dontrun{
#' download_data(
Expand Down Expand Up @@ -145,7 +145,7 @@ download_data <-
#' @param remove_zip logical(1). Remove zip file from directory_to_download.
#' Default \code{FALSE}.
#' @author Mariana Kassien, Insang Song, Mitchell Manware
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -318,7 +318,7 @@ download_aqs <-
#' @param remove_zip logical(1). Remove zip file from
#' \code{directory_to_download}. Default \code{FALSE}.
#' @author Insang Song
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' \code{directory_to_save}.
#' @importFrom utils download.file
#' @importFrom Rdpack reprompt
Expand Down Expand Up @@ -447,7 +447,7 @@ download_ecoregion <- function(
#' Remove (\code{TRUE}) or keep (\code{FALSE})
#' the text file containing download commands.
#' @author Mitchell Manware, Insang Song
#' @returns NULL; netCDF (.nc4) files will be stored in a
#' @return NULL; netCDF (.nc4) files will be stored in a
#' collection-specific folder within \code{directory_to_save}.
#' @importFrom utils download.file
#' @importFrom Rdpack reprompt
Expand Down Expand Up @@ -625,7 +625,7 @@ download_geos <- function(
#' Default is \code{FALSE}.
#' @author Mitchell Manware, Insang Song
# nolint end
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -777,7 +777,7 @@ download_gmted <- function(
#' Remove (\code{TRUE}) or keep (\code{FALSE})
#' the text file containing download commands.
#' @author Mitchell Manware, Insang Song
#' @returns NULL; netCDF (.nc4) files will be stored in a
#' @return NULL; netCDF (.nc4) files will be stored in a
#' collection-specific folder within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -1188,7 +1188,7 @@ download_merra2 <- function(
#' Remove (\code{TRUE}) or keep (\code{FALSE})
#' the text file containing download commands.
#' @author Mitchell Manware, Insang Song
#' @returns NULL; netCDF (.nc) files will be stored in
#' @return NULL; netCDF (.nc) files will be stored in
#' \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -1340,7 +1340,7 @@ download_narr <- function(
#' @param remove_zip logical(1). Remove zip files from directory_to_download.
#' Default is \code{FALSE}.
#' @author Mitchell Manware, Insang Song
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' respective sub-directories within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -1499,7 +1499,7 @@ download_nlcd <- function(
#' @param remove_zip logical(1). Remove zip files from directory_to_download.
#' Default is \code{FALSE}.
#' @author Mitchell Manware, Insang Song
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' respective sub-directories within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -1657,7 +1657,7 @@ download_sedac_groads <- function(
#' Default is \code{FALSE}.
#' @author Mitchell Manware, Insang Song
# nolint end
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' respective sub-directories within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -1824,7 +1824,7 @@ download_sedac_population <- function(
#' Download wildfire smoke data
#' @description
#' The \code{download_hms()} function accesses and downloads
#' wildfire smoke plume coverage data from [NOAA's Hazard Mapping System Fire and Smoke Product](https://www.ospo.noaa.gov/Products/land/hms.html#0).
#' wildfire smoke plume coverage data from [NOAA's Hazard Mapping System Fire and Smoke Product](https://www.ospo.noaa.gov/products/land/hms.html#0).
#' @param data_format character(1). "Shapefile" or "KML".
#' @param date character(2). length of 10 each. Start/end date for downloading data.
# nolint end
Expand All @@ -1851,7 +1851,7 @@ download_sedac_population <- function(
#' @importFrom utils head
#' @importFrom utils tail
#' @author Mitchell Manware, Insang Song
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' respective sub-directories within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -2040,7 +2040,7 @@ download_hms <- function(
#' @param remove_zip logical(1). Remove zip files from directory_to_download.
#' Default is \code{FALSE}.
#' @author Mitchell Manware, Insang Song
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' respective sub-directories within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -2192,7 +2192,7 @@ download_koppen_geiger <- function(
#' the text file containing download commands.
#' @author Mitchell Manware, Insang Song
#' @import rvest
#' @returns NULL; HDF (.hdf) files will be stored in
#' @return NULL; HDF (.hdf) files will be stored in
#' \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -2565,7 +2565,7 @@ download_modis <- function(
# nolint start
#' Download toxic release data
#' @description
#' The \code{download_tri()} function accesses and downloads toxic release data from the [U.S. Environmental Protection Agency's (EPA) Toxic Release Inventory (TRI) Program](https://www.epa.gov/toxics-release-inventory-tri-program/find-understand-and-use-tri).
#' The \code{download_tri()} function accesses and downloads toxic release data from the [U.S. Environmental Protection Agency's (EPA) Toxic Release Inventory (TRI) Program](https://www.epa.gov/toxics-release-inventory-tri-program/tri-data-action-0).
#' @param year character(2). length of 4 each. Start/end years for downloading data.
# nolint end
#' @param directory_to_save character(1). Directory to download files.
Expand All @@ -2578,7 +2578,7 @@ download_modis <- function(
#' @param remove_command logical(1). Remove (\code{TRUE}) or keep (\code{FALSE})
#' the text file containing download commands.
#' @author Mariana Kassien, Insang Song
#' @returns NULL; Comma-separated value (CSV) files will be stored in
#' @return NULL; Comma-separated value (CSV) files will be stored in
#' \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -2701,7 +2701,7 @@ download_tri <- function(
#' Currently we bundle the pre-downloaded crt and its PEM (which is accepted
#' in wget command) file in ./inst/extdata. The instruction above is for
#' certificate updates in the future.
#' @returns NULL; Zip and/or data files will be downloaded and stored in
#' @return NULL; Zip and/or data files will be downloaded and stored in
#' respective sub-directories within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -2822,7 +2822,7 @@ download_nei <- function(
# nolint start
#' Download OpenLandMap data
#' @description
#' Accesses and downloads OpenLandMap data from the [OpenLandMap website](https://www.openlandmap.org/).
#' Accesses and downloads OpenLandMap data from the [OpenLandMap website](https://opengeohub.org/about-openlandmap/).
#' @param product character(1). Available collection name in OpenLandMap
#' STAC Catalog. [list_stac_files] with `id_only = TRUE` to see available collections.
#' * "no2_s5p.l3.trop.tmwm"
Expand Down Expand Up @@ -2913,7 +2913,7 @@ download_nei <- function(
#' @note `extdata/openlandmap_assets.rds` contains the available assets in OpenLandMap.
#' Users may want to check the available assets to download data directly.
#' For developers: JSON files should be found at STAC catalog of OpenLandMap when updated.
#' @returns NULL; GeoTIFF (.tif) files will be stored in
#' @return NULL; GeoTIFF (.tif) files will be stored in
#' \code{directory_to_save}.
#' @seealso [list_stac_files]
#' @importFrom Rdpack reprompt
Expand Down Expand Up @@ -3024,7 +3024,7 @@ download_olm <- function(
#' the text file containing download commands.
#' @param unzip logical(1). Unzip the downloaded compressed files.
#' Default is \code{FALSE}. Not working for this function since HUC data is in 7z format.
#' @returns NULL. Downloaded files will be stored in \code{directory_to_save}.
#' @return NULL. Downloaded files will be stored in \code{directory_to_save}.
#' @author Insang Song
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -3155,7 +3155,7 @@ download_huc <-
#' Accesses and downloads United States Department of Agriculture
#' CropScape Cropland Data Layer data from
#' the [USDA National Agricultural Statistics Service](https://www.nass.usda.gov/Research_and_Science/Cropland/Release/index.php) or the
#' [George Mason University website](https://https://nassgeodata.gmu.edu/CropScape/).
#' [George Mason University website](https://nassgeodata.gmu.edu/CropScape/).
#' @param year integer(1). Year of the data to download.
#' @param source character(1). Data source, one of `c("USDA", "GMU")`.
#' * `"USDA"` will download the national data from the USDA website (available in 2008-last year).
Expand All @@ -3174,7 +3174,7 @@ download_huc <-
#' Default is \code{FALSE}.
#' @author Insang Song
#' @note JSON files should be found at STAC catalog of OpenLandMap
#' @returns NULL; Yearly comma-separated value (CSV) files will be stored in
#' @return NULL; Yearly comma-separated value (CSV) files will be stored in
#' \code{directory_to_save}.
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -3322,7 +3322,7 @@ download_cropscape <- function(
#' Remove (\code{TRUE}) or keep (\code{FALSE})
#' the text file containing download commands.
#' @author Insang Song
#' @returns NULL; .bil (normals) or single grid files depending on the format
#' @return NULL; .bil (normals) or single grid files depending on the format
#' choice will be stored in \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand All @@ -3341,7 +3341,7 @@ download_cropscape <- function(
#' )
#' }
#' @references
#' * [PRISM Climate Group](http://www.prism.oregonstate.edu/)
#' * [PRISM Climate Group](https://prism.oregonstate.edu/)
#' * [PRISM Web Service Guide](https://prism.oregonstate.edu/documents/PRISM_downloads_web_service.pdf)
#' @export
# nolint end
Expand Down Expand Up @@ -3458,7 +3458,7 @@ download_prism <- function(
#' Remove (\code{TRUE}) or keep (\code{FALSE})
#' the text file containing download commands.
#' @author Mitchell Manware
#' @returns NULL; netCDF (.nc) files will be stored in a variable-specific
#' @return NULL; netCDF (.nc) files will be stored in a variable-specific
#' folder within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand All @@ -3468,7 +3468,7 @@ download_prism <- function(
#' download_gridmet(
#' variables = "Precipitation",
#' year = c(2023, 2024),
#' directory_to_save = "./data"
#' directory_to_save = "./data",
#' acknowledgement = TRUE,
#' download = TRUE,
#' remove_command = TRUE
Expand Down Expand Up @@ -3600,7 +3600,7 @@ download_gridmet <- function(
#' Remove (\code{TRUE}) or keep (\code{FALSE})
#' the text file containing download commands.
#' @author Mitchell Manware, Insang Song
#' @returns NULL; netCDF (.nc) files will be stored in a variable-specific
#' @return NULL; netCDF (.nc) files will be stored in a variable-specific
#' folder within \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand All @@ -3610,7 +3610,7 @@ download_gridmet <- function(
#' download_terraclimate(
#' variables = "Precipitation",
#' year = c(2023, 2024),
#' directory_to_save = "./data"
#' directory_to_save = "./data",
#' acknowledgement = TRUE,
#' download = TRUE,
#' remove_command = TRUE
Expand Down
Loading

0 comments on commit b63e8ea

Please sign in to comment.