Get a smoothed cover of a raster object. From all non-missing values of a raster object, a 2D kernal density is applied. The output is a sf
object of spatial polygons. Used by smooth_map
. Note that this function supports sf
objects, but still uses sp-based methods (see details). Note that this function supports sf
objects, but still uses sp-based methods (see details).
smooth_raster_cover(shp, var = NULL, bandwidth = NA, threshold = 0.6,
output = "polygons")
raster object, from either SpatialGrid(DataFrame)
or Raster
class.
name of the variable from which missing values are flagged. If unspecified, the first variable will be taken.
single numeric value or vector of two numeric values that specifiy the bandwidth of the kernal density estimator. See details.
numeric value between 0 and 1 that determines which part of the estimated 2D kernal density is returned as cover.
For the estimation of the 2D kernal density, code is borrowed from bkde2D
. This implemention is slightly different: bkde2D
takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of var
are not missing and 0 if values of var
are missing.
This function supports sf
objects, but still uses sp-based methods, from the packages sp, rgeos, and/or rgdal.