An sf tibble of grid cells with corresponding point
counts and dual kernel density estimates for each cell. This can be plotted
using autoplot.
This function creates a regular two-dimensional grid of cells (unless a
custom grid is specified with grid), calculates the density of points
in each cell for each of x and y using functions from the
SpatialKDE package, then produces a value representing a relation
between the two densities. The count of points in each cell is also returned.
Dual kernel density values can be useful for understanding the relationship
between the distributions of two sets of point locations. For example:
The ratio between two densities representing the locations of burglaries
and the locations of houses can show the distribution of the risk
(incidence rate) of burglaries. The logged ratio may be useful to show
relationships where one set of points has an extremely skewed
distribution.
The difference between two densities can show the change in distributions
between two points in time.
The sum of two densities can be used to estimate the total density of two
types of point, e.g. the locations of occurrences of two diseases.
Coverage of the output data
The grid produced by this function covers the convex hull of the points in
x. 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 x 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.