| Type: | Package | 
| Title: | Kernel Density Estimation for Spatial Data | 
| Version: | 0.8.2 | 
| URL: | https://jancaha.github.io/SpatialKDE/index.html, https://github.com/JanCaha/SpatialKDE | 
| Description: | Calculate Kernel Density Estimation (KDE) for spatial data. The algorithm is inspired by the tool 'Heatmap' from 'QGIS'. The method is described by: Hart, T., Zandbergen, P. (2014) <doi:10.1108/PIJPSM-04-2013-0039>, Nelson, T. A., Boots, B. (2008) <doi:10.1111/j.0906-7590.2008.05548.x>, Chainey, S., Tompson, L., Uhlig, S.(2008) <doi:10.1057/palgrave.sj.8350066>. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.2.3 | 
| VignetteBuilder: | knitr | 
| LinkingTo: | cpp11, progress | 
| Imports: | sf, dplyr, glue, magrittr, rlang, vctrs, methods, raster | 
| Suggests: | tmap, sp, knitr, rmarkdown, testthat (≥ 2.99.0), xml2 | 
| Config/testthat/edition: | 3 | 
| NeedsCompilation: | yes | 
| Packaged: | 2023-02-18 14:21:48 UTC; cahik | 
| Author: | Jan Caha | 
| Maintainer: | Jan Caha <jan.caha@outlook.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2023-02-18 15:10:02 UTC | 
Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
Create grid
Description
Create grid of equally spaced rectangles or hexagons. The distance between centre points
in both x and y dimension is equal to cell_size. The function is effectively a wrapper around
st_make_grid with a little bit of preprocessing including generation of grid only inside
st_convex_hull.
Usage
create_grid_rectangular(
  geometry,
  cell_size,
  side_offset = 0,
  only_inside = FALSE
)
create_grid_hexagonal(
  geometry,
  cell_size,
  side_offset = 0,
  only_inside = FALSE
)
Arguments
| geometry | 
 | 
| cell_size | 
 | 
| side_offset | 
 | 
| only_inside | 
 | 
Value
sf data.frame.
Functions
-  create_grid_rectangular(): Create rectangular grid
-  create_grid_hexagonal(): Create hexagonal grid
Examples
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf")) %>% st_transform(32031)
grid <- create_grid_hexagonal(nc, cell_size = 100000)
grid <- create_grid_rectangular(nc, cell_size = 100000, only_inside = TRUE)
Create raster
Description
Create raster of equally spaced cells. The distance between centre of cells
in both x and y dimension is equal to cell_size.
Usage
create_raster(geometry, cell_size, side_offset = 0)
Arguments
| geometry | 
 | 
| cell_size | 
 | 
| side_offset | 
 | 
Value
Examples
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf")) %>% st_transform(32031)
raster <- create_raster(nc, cell_size = 100000)
Kernel Density Estimation
Description
KDE for spatial data. The algorithm is heavily inspired by Heatmap tool in QGIS. The help for QGIS tools is provided at the QGIS website. The a tutorial is provided here.
Usage
kde(
  points,
  band_width,
  decay = 1,
  kernel = c("quartic", "uniform", "triweight", "epanechnikov", "triangular"),
  scaled = FALSE,
  weights = c(),
  grid,
  cell_size,
  quiet = FALSE
)
Arguments
| points | 
 | 
| band_width | 
 | 
| decay | 
 | 
| kernel | 
 | 
| scaled | 
 | 
| weights | 
 | 
| grid | either  | 
| cell_size | 
 | 
| quiet | Should printing of progress bar be suppressed? Default 'FALSE'. | 
Details
grid parameter specifies output of the function. KDE is calculated on the specified grid.
If grid is Raster-class then outcome is also Raster-class.
If grid is sf data.frame then outcome is also sf data.frame.
Value
either sf data.frame or Raster-class
depending on class of grid parameter.
Examples
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf")) %>% st_transform(32031)
grid <- create_grid_hexagonal(nc, cell_size = 100000)
points <- st_sample(nc, 500) %>% st_as_sf()
kde_estimate_grid <- kde(points, band_width = 150000, grid = grid)
raster <- create_raster(nc, cell_size = 100000)
kde_estimate_raster <- kde(points, band_width = 150000, grid = raster)