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 SpatialPolygons object. Used by smooth_map
.
smooth_raster_cover(shp, var = NULL, bandwidth = NA, threshold = 0.6,
output = "SpatialPolygons")
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 specify 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.
class of the returned object. One of: SpatialPolygons
, SpatialLines
, SpatialGridDataFrame
, or RasterLayer
. A vector of class names results in a list of output objects.
For the estimation of the 2D kernal density, code is borrowed from bkde2D
. This implementation 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.
Tennekes, M., 2018, tmap: Thematic Maps in R, Journal of Statistical Software, 84(6), 1-39, DOI