# \donttest{
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)
pt.kde <- sf.kde(x = meuse, bw = 1000, standardize = TRUE,
scale.factor = 10000, res=40)
plot(pt.kde, main="Unweighted kde")
plot(st_geometry(meuse), pch=20, col="red", add=TRUE)
# Weighted KDE using cadmium and extent with automatic bandwidth selection
( e <- st_bbox(meuse)[c(1,3,2,4)] )
cadmium.kde <- sf.kde(x = meuse, y = meuse$cadmium, ref = e,
standardize = TRUE,
scale.factor = 10000, res=40)
plot(cadmium.kde)
plot(st_geometry(meuse), pch=20, col="red", add=TRUE)
# }
Run the code above in your browser using DataLab