Skip to contents

Calculate Sum of Exponentially Decaying Contributions (SEDC) covariates

Usage

summarize_sedc(
  point_from = NULL,
  point_to = NULL,
  id = NULL,
  sedc_bandwidth = NULL,
  threshold = NULL,
  target_fields = NULL,
  extent_from = NULL,
  extent_to = NULL,
  ...
)

Arguments

point_from

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

point_to

SpatVector object. Locations where each SEDC is calculated.

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 %)

threshold

numeric(1). For computational efficiency, the nearest points in threshold will be selected. 2 * sedc_bandwidth is applied if this value remains NULL.

target_fields

character. Field names to calculate SEDC.

extent_from

numeric(4) or SpatExtent. Extent of clipping point_from. It only works with point_from of character(1) file path. See terra::ext for more details. Coordinate systems should match.

extent_to

numeric(4) or SpatExtent. Extent of clipping point_to.

...

Placeholder.

Value

data.frame (tibble) 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

Distance calculation is done with terra functions internally. Thus, the function internally converts sf objects in point_* arguments to terra. Please note that any NA values in the input will be ignored in SEDC calculation.

See also

Other Macros for calculation: extract_at(), extract_at_buffer(), extract_at_poly(), kernelfunction(), summarize_aw()

Author

Insang Song

Examples

library(terra)
library(sf)
set.seed(101)
ncpath <- system.file("gpkg/nc.gpkg", package = "sf")
nc <- terra::vect(ncpath)
nc <- terra::project(nc, "EPSG:5070")
pnt_from <- terra::centroids(nc, inside = TRUE)
pnt_from <- pnt_from[, "NAME"]
pnt_to <- terra::spatSample(nc, 100L)
pnt_to$pid <- seq(1, 100)
pnt_to <- pnt_to[, "pid"]
pnt_to$val1 <- rgamma(100L, 1, 0.05)
pnt_to$val2 <- rgamma(100L, 2, 1)

vals <- c("val1", "val2")
summarize_sedc(pnt_from, pnt_to, "NAME", 1e5, 2e5, vals)
#> # A tibble: 100 × 3
#>    NAME      val1_sedc val2_sedc
#>    <chr>         <dbl>     <dbl>
#>  1 Alamance       66.3      6.71
#>  2 Alexander      98.0     11.7 
#>  3 Alleghany     135.       8.57
#>  4 Anson          50.0      5.23
#>  5 Ashe          143.       8.42
#>  6 Avery          76.1      8.76
#>  7 Beaufort       58.8      6.29
#>  8 Bertie         70.1      7.85
#>  9 Bladen         79.5      6.82
#> 10 Brunswick      54.3      5.34
#> # ℹ 90 more rows