SpatialKDE implements kernel density estimation for spatial data with all the necessary settings, including selection of bandwidth, kernel type and underlying grid (cell size and shape). The algorithm is based on Heatmap tool from QGIS. The tool is adapted directly from source code. Example tutorial about the QGIS tool is available here.

First we load all necessary packages.

Then we load the example dataset and prepare it into expected format of `sf`

`data.frame`

.

```
data(meuse)
meuse <- meuse %>%
st_as_sf(coords = c("x", "y"), dim = "XY") %>%
st_set_crs(28992) %>%
select()
```

Letâ€™s define variables necessary for KDE estimation, cell size of the resulting grid and band width of points.

Now we can prepare grid for KDE estimation. We prepare rectangular grid (hexagonal is the second option) with given cell size which is slightly bigger than convex hull of the data.

At this moment it is possible to calculate KDE using `kde()`

function with specified settings.

`## Using centroids instead of provided `grid` geometries to calculate KDE estimates.`

The result can be visualized using `tmap`

package.

Now we can prepare raster for KDE estimation. We prepare raster with given cell size which is slightly bigger than convex hull of the data.

At this moment it is possible to calculate KDE using `kde()`

function with specified settings.

The result can be visualized using `tmap`

package.