Learn R Programming

tmaptools (version 2.0-2)

smooth_raster_cover: Get a smoothed cover of a raster object (deprecated)

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

Usage

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

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: polygons (sf object), lines (sf object), or a raster. 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.

This function supports sf objects, but still uses sp-based methods, from the packages sp, rgeos, and/or rgdal.