gridensity {icosa} | R Documentation |
Icosahedral grid-based density estimation
Description
Spatial density estimation algorithm based on rotation of icosahedral grids.
Usage
gridensity(x, y, out, trials = 100, FUN = mean)
Arguments
x |
Matrix of longitude, latitude data, |
y |
|
out |
|
trials |
|
FUN |
|
Details
Any points set can be binned to an icosahedral grid (i.e. number of incidences can be counted), which will be dependent on the exact positions of grid cells. Rotating the grid in 3d space will result in a different distribution of counts. This distribution can be resampled to a standard orientation structure. The size of the icosahedral grid cells act as a bandwidth parameter.
The implemented algorithm 1) takes a point cloud (x
)) and an icosahedral grid y
2) randomly rotates the icosahedral grid, 3) looks up the points falling on grid cells, 4) resamples the grid to a constant orientation object (either trigrid
, hexagrid
or SpatRaster
). Steps 2-4 are repeated trial
times, and then FUN
is applied to every vector of values that have same spatial position.
Value
Either named numeric vector, or a SpatRaster
object. If FUN is set to NULL
, the output will be either a matrix
or SpatRaster
.
Examples
# example to be run if terra is present
if(requireNamespace("terra", quietly=TRUE)){
# randomly generated points
x <- rpsphere(100, output="polar")
# bandwidth grid
y <- hexagrid(deg=13)
# output structure
out <- terra::rast(res=5)
# the function
o <- gridensity(x, y, out, trials=7)
# visualize results
terra::plot(o)
points(x, pch=3)
}