hotspot_kde {sfhotspot} | R Documentation |
Estimate two-dimensional kernel density of points
Description
Estimate two-dimensional kernel density of points
Usage
hotspot_kde(
data,
cell_size = NULL,
grid_type = "rect",
bandwidth = NULL,
bandwidth_adjust = 1,
grid = NULL,
weights = NULL,
quiet = FALSE,
...
)
Arguments
data |
|
cell_size |
|
grid_type |
|
bandwidth |
|
bandwidth_adjust |
single positive |
grid |
|
weights |
|
quiet |
if set to |
... |
Further arguments passed to |
Details
This function creates a regular two-dimensional grid of cells (unless a
custom grid is specified with grid
) and calculates the density of
points in each cell on that grid using functions from the SpatialKDE
package. The count of points in each cell is also returned.
Coverage of the output data
The grid produced by this function covers the convex hull of the input data
layer. This means the result may include KDE values for cells that are
outside the area for which data were provided, which could be misleading. To
handle this, consider cropping the output layer to the area for which data
are available. For example, if you only have crime data for a particular
district, crop the output dataset to the district boundary using
st_intersection
.
Automatic cell-size selection
If no cell size is given then the cell size will be set so that there are 50
cells on the shorter side of the grid. If the data
SF object is projected
in metres or feet, the number of cells will be adjusted upwards so that the
cell size is a multiple of 100.
Value
An sf
tibble of grid cells with corresponding point
counts and kernel density estimates for each cell. This can be plotted
using autoplot
.
References
Yin, P. (2020). Kernels and Density Estimation. The Geographic Information Science & Technology Body of Knowledge (1st Quarter 2020 Edition), John P. Wilson (ed.). doi:doi:10.22224/gistbok/2020.1.12
Examples
library(sf)
# Transform data to UTM zone 15N so that cell_size and bandwidth can be set
# in metres
memphis_robberies_utm <- st_transform(memphis_robberies_jan, 32615)
# Automatically set grid-cell size, bandwidth and neighbour distance
hotspot_kde(memphis_robberies_utm)
# Manually set grid-cell size and bandwidth in metres, since the
# `memphis_robberies_utm` dataset uses a co-ordinate reference system (UTM
# zone 15 north) that is specified in metres
hotspot_kde(memphis_robberies_utm, cell_size = 200, bandwidth = 1000)