Skip to contents

Calculate Sum of Exponentially Decaying Contributions (SEDC) covariates

Usage

calc_sedc(
  from = NULL,
  locs = NULL,
  locs_id = NULL,
  sedc_bandwidth = NULL,
  target_fields = NULL,
  geom = FALSE
)

Arguments

from

SpatVector object. Locations where each SEDC is calculated.

locs

SpatVector object. Locations where the sum of SEDCs are calculated.

locs_id

character(1). Name of the unique id field in point_to.

sedc_bandwidth

numeric(1). Distance at which the source concentration is reduced to exp(-3) (approximately -95 %)

target_fields

character(varying). Field names in characters.

geom

logical(1). Should the function return a SpatVector? Default is FALSE. The coordinate reference system of the SpatVector is that of from.

Value

a data.frame (tibble) or SpatVector object with input field names with a suffix "_sedc" where the sums of EDC are stored. Additional attributes are attached for the EDC information.

  • `attr(result, "sedc_bandwidth")“: the bandwidth where concentration reduces to approximately five percent

  • `attr(result, "sedc_threshold")“: the threshold distance at which emission source points are excluded beyond that

Note

The function is originally from chopin Distance calculation is done with terra functions internally. Thus, the function internally converts sf objects in point_* arguments to terra. The threshold should be carefully chosen by users.

References

messier2012integratingamadeus

web_sedctutorial_packageamadeus

Author

Insang Song

Examples

library(terra)
#> terra 1.7.78
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
set.seed(101)
ncpath <- system.file("gpkg/nc.gpkg", package = "sf")
nc <- terra::vect(ncpath)
nc <- terra::project(nc, "EPSG:5070")
pnt_locs <- terra::centroids(nc, inside = TRUE)
pnt_locs <- pnt_locs[, "NAME"]
pnt_from <- terra::spatSample(nc, 10L)
pnt_from$pid <- seq(1, 10)
pnt_from <- pnt_from[, "pid"]
pnt_from$val1 <- rgamma(10L, 1, 0.05)
pnt_from$val2 <- rgamma(10L, 2, 1)

vals <- c("val1", "val2")
calc_sedc(pnt_locs, pnt_from, "NAME", 1e4, vals)
#> Joining with `by = join_by(from_id)`
#> Joining with `by = join_by(to_id)`
#> Joining with `by = join_by(from_id, to_id)`
#>         NAME       val1        val2
#> 1  Currituck 0.39651678 0.119400641
#> 2   Franklin 0.00767532 0.000963305
#> 3    Madison 0.00858568 0.003998301
#> 4       Polk 0.06034160 0.003668522
#> 5   Randolph 0.03433355 0.046817979
#> 6 Rutherford 0.11657394 0.007087217
#> 7     Stokes 0.04433759 0.004935366
#> 8     Yancey 0.05592440 0.026043667