Skip to contents

Overlay specified SDM predictions that meet the percent overlap threshold requirement onto base geometry

Usage

overlay_sdm(base.geom, sdm, sdm.idx, overlap.perc)

Arguments

base.geom

object of class sfc; base geometry

sdm

object of class sf; original SDM predictions

sdm.idx

names or indices of column(s) with data to be overlaid

overlap.perc

numeric; percent overlap threshold, i.e. percentage of each base geometry polygon must overlap with SDM prediction polygons for overlaid density value to be calculated and not set as NA

Value

Object of class sf with the geometry of base.geom and the data in the sdm.idx columns of sdm overlaid onto that geometry. Note that this means all columns of sdm not in

sdm.idx will not be in the returned object. Because the data are considered spatially intensive, the agr

attribute will be set as 'constant' for all columns in the returned object

Details

See the eSDM GUI manual for specifics about the overlay process. This process is equivalent to areal interpolation (Goodchild and Lam 1980), where base.geom is the target, sdm is the source, and the data specified by sdm.idx are spatially intensive.

Note that overlay_sdm removes rows in sdm that have NA values in the first column specified in sdm.idx (i.e. sdm.idx[1]), before the overlay. Thus, for valid overlay results, all columns of sdm specified in sdm.idx must either have NA values in the same rows or contain only NAs.

References

Goodchild, M.F. & Lam, N.S.-N. (1980) Areal interpolation: a variant of the traditional spatial problem. Geo-Processing, 1, 297-312.

Examples

pol1.geom <- sf::st_sfc(
  sf::st_polygon(list(rbind(c(1,1), c(3,1), c(3,3), c(1,3), c(1,1)))),
  crs = 4326
)
pol2.geom <- sf::st_sfc(
  sf::st_polygon(list(rbind(c(0,0), c(2,0), c(2,2), c(0,2), c(0,0)))),
  crs = 4326
)
pol2.sf <- sf::st_sf(data.frame(Dens = 0.5), geometry = pol2.geom, crs = 4326)

overlay_sdm(pol1.geom, pol2.sf, 1, 25)
#> Simple feature collection with 1 feature and 1 field
#> Attribute-geometry relationship: constant (1)
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1 ymin: 1 xmax: 3 ymax: 3
#> Geodetic CRS:  WGS 84
#>   Dens                       geometry
#> 1  0.5 POLYGON ((1 1, 3 1, 3 3, 1 ...

# Output 'Dens' value is NA because of higher overlap.perc value
overlay_sdm(pol1.geom, pol2.sf, 1, 50)
#> Simple feature collection with 1 feature and 1 field
#> Attribute-geometry relationship: constant (1)
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1 ymin: 1 xmax: 3 ymax: 3
#> Geodetic CRS:  WGS 84
#>   Dens                       geometry
#> 1   NA POLYGON ((1 1, 3 1, 3 3, 1 ...

if (FALSE) {
# These examples take longer to run
overlay_sdm(sf::st_geometry(preds.1), preds.2, 1, 50)
overlay_sdm(sf::st_geometry(preds.2), preds.1, "Density", 50)
}