sf.kde: Spatial kernel density estimate

View source: R/sf.kde.R

sf.kdeR Documentation

Spatial kernel density estimate

Description

A weighted or unweighted Gaussian Kernel Density estimate for point spatial data

Usage

sf.kde(
  x,
  y = NULL,
  bw = NULL,
  ref = NULL,
  res = NULL,
  standardize = FALSE,
  scale.factor = 10000,
  mask = FALSE
)

Arguments

x

sf POINT object

y

Optional values, associated with x coordinates, to be used as weights

bw

Distance bandwidth of Gaussian Kernel, must be units of projection

ref

A terra SpatRaster, sf class object or c[xmin,xmax,ymin,ymax] vector to estimate the kde extent

res

Resolution of raster when ref not SpatRaster

standardize

Standardize results to 0-1 (FALSE/TRUE)

scale.factor

Numeric scaling factor for the KDE (defaults to 10000), to account for very small estimate values

mask

(TRUE/FALSE) mask resulting raster if ref is provided as a SpatRaster

Details

Please note that ks methods for estimation has been reverted to the Gussian method proposed in Venables & Ripley (2002). There was not enought evendence that the Chacon & Duong (2018) multivariate method(s) for bandwidth selection and kernal estimation were suitable for spatial random fields.

Value

a terra SpatRaster class object containing kernel density estimate

Author(s)

Jeffrey S. Evans <jeffrey_evans@tnc.org>

References

Duong, T. & Hazelton, M.L. (2005) Cross-validation bandwidth matrices for multivariate kernel density estimation. Scandinavian Journal of Statistics, 32, 485-506.

Wand, M.P. & Jones, M.C. (1994) Multivariate plug-in bandwidth selection. Computational Statistics, 9, 97-116.

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

Examples

 
library(sf) 
library(terra) 
  
data(meuse, package = "sp")
meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 
                  agr = "constant") 
  			
# Unweighted KDE (spatial locations only) with 40m resoultion  				
pt.kde <- sf.kde(x = meuse, bw = 1000, standardize = TRUE, res=40)
  plot(pt.kde, main="Unweighted kde")
    plot(st_geometry(meuse), pch=20, col="red", add=TRUE) 

# cadmium weighted KDE usign extent with 40m resoultion and 500m and 1000m bw 
cadmium.kde.500 <- sf.kde(x = meuse, y = meuse$cadmium, res=40, 
                          bw = 500, standardize = TRUE)
cadmium.kde.1000 <- sf.kde(x = meuse, y = meuse$cadmium, res=40, 
                          bw = 1000, standardize = TRUE)						  
  plot(c(cadmium.kde.500, cadmium.kde.1000))
  			  			



spatialEco documentation built on Nov. 18, 2023, 1:13 a.m.