Skip to contents

Computes kernel density estimates for point or polygon sf objects.

Usage

st_density(
  x,
  method = c("kde", "kriging"),
  bandwidth = NULL,
  n = 100,
  weights = NULL,
  ...
)

Arguments

x

An sf object with point or polygon geometries

method

Density estimation method: "kde" (kernel density) or "kriging" (requires additional packages)

bandwidth

Bandwidth for KDE. If NULL, estimated automatically.

n

Grid size for density estimation

weights

Optional weights for each feature

...

Additional arguments passed to density estimation functions

Value

A list with density estimates and grid information

Examples

library(sf)
# Create random points
pts <- st_as_sf(data.frame(
  x = rnorm(100),
  y = rnorm(100)
), coords = c("x", "y"))

# Compute density
dens <- st_density(pts)