knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

The following code illustrates how to use the robust.quadcount function:

library(magrittr)
library(robustmap)

# Loading burglary data points
file1 = system.file("extdata/burglary.shp", package = "robustmap")

burglary <- sf::read_sf(file1)
burglary <- data.frame(x=burglary$lon_m,
                       y=burglary$lat_m)

# Running robust_quadcount with default parameters
burglary_map <- burglary %>% robust.quadcount(nsamples=200)

Once the function returns, the optimal granularity (in the same unit of the original coordinates) can be retrieved by:

burglary_map$opt_granularity

The map of burglary counts can be plotted using:

```r

Plotting the final map

terra::plot(burglary_map$counts)



rafaelgramos/robustmap documentation built on April 22, 2024, 8:22 a.m.