Learn R Programming

tmaptools (version 1.2)

smooth_raster_cover: Get a smoothed cover of a raster object

Description

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.

Usage

smooth_raster_cover(shp, var = NULL, bandwidth = NA, threshold = 0.6, output = "SpatialPolygons")

Arguments

shp
raster object, from either SpatialGrid(DataFrame) or Raster class.
var
name of the variable from which missing values are flagged. If unspecified, the first variable will be taken.
bandwidth
single numeric value or vector of two numeric values that specifiy the bandwidth of the kernal density estimator. See details.
threshold
numeric value between 0 and 1 that determines which part of the estimated 2D kernal density is returned as cover.
output
class of the returned object. One of: SpatialPolygons, SpatialLines, SpatialGridDataFrame, or RasterLayer. A vector of class names results in a list of output objects.

Details

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.