overlay_sdm: Overlay SDM predictions onto base geometry

View source: R/overlay_sdm.R

overlay_sdmR Documentation

Overlay SDM predictions onto base geometry

Description

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

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.

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.

Additionally, the output will match the class of sdm, with regards to the classes tbl_df, tbl, and data.frame. This means that, in addition to being an sf object, if sdm is a tibble then the output will also be a tibble, while if sdm is just a data frame then the output will not be a tibble.

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 = sf::st_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 = sf::st_crs(4326)
)
pol2.sf <- sf::st_sf(data.frame(Dens = 0.5), geometry = pol2.geom,
                     crs = sf::st_crs(4326))

overlay_sdm(pol1.geom, pol2.sf, 1, 25)

# Output 'Dens' value is NA because of higher overlap.perc value
overlay_sdm(pol1.geom, pol2.sf, 1, 50)


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


eSDM documentation built on Oct. 8, 2024, 1:07 a.m.