Skip to contents

The calculate_covariates() function extracts values at point locations from a SpatRaster or SpatVector object returned from process_covariates(). calculate_covariates() and the underlying source-specific covariate functions have been designed to operate on the processed objects. To avoid errors, do not edit the processed SpatRaster or SpatVector objects before passing to calculate_covariates().

Usage

calculate_covariates(
  covariate = c("modis", "koppen-geiger", "koeppen-geiger", "koppen", "koeppen", "geos",
    "dummies", "gmted", "sedac_groads", "groads", "roads", "ecoregions", "ecoregion",
    "hms", "smoke", "gmted", "narr", "geos", "sedac_population", "population", "nlcd",
    "merra", "merra2", "gridmet", "terraclimate", "tri", "nei", "mcd14ml", "prism",
    "cropscape", "cdl", "huc", "edgar", "goes", "goes_adp", "GOES", "drought", "spei",
    "eddi", "usdm"),
  from,
  locs,
  locs_id = "site_id",
  .by_time = NULL,
  weights = NULL,
  ...
)

Arguments

covariate

character(1). Covariate type.

from

character, SpatRaster, SpatVector, or data.frame depending on the selected covariate route.

locs

sf/SpatVector. Unique locations. Should include a unique identifier field named locs_id

locs_id

character(1). Name of unique identifier. Default is "site_id".

.by_time

NULL or character(1). Name of the time column to use temporal summarization unit token. NULL (default) disables temporal summarization.

weights

NULL, SpatRaster, polygon SpatVector/sf, or file path. Passed through to the underlying source-specific function for weighted extraction. If NULL (default), unweighted extraction is performed.

...

Arguments passed to each covariate calculation function.

Value

Calculated covariates as a data.frame or SpatVector object

Note

covariate argument value is converted to lowercase.

See also

Author

Insang Song

Examples

## NOTE: Example is wrapped in `\dontrun{}` as function requires a large
##       amount of data which is not included in the package.
if (FALSE) { # \dontrun{
loc <- data.frame(id = "001", lon = -78.90, lat = 35.97)
calculate_covariates(
  covariate = "narr",
  from = narr, # derived from process_covariates() example
  locs = loc,
  locs_id = "id",
  geom = FALSE
)
} # }