if (FALSE) {
# Dummy example!
require(data.table, sf, mapi, spatstat.geom, spatstat.core)
data("samples")
keep <- c(2,3,6,9,10,11,16,18,19,20,21,23,26,27,29,31,33,34,38,41,46,50,54,58,61,63,65,71,72,73,
76,78,79,81,85,92,93,94,97,98,99,101,103,113,115,119,120,121,124,127,130,134,142,143,151,152,159,
160,176,185,189,191,195,196,197,198,199)
samples2 <- samples[keep, ] # keep only one third in order to create discontinuities
set.seed(1234)
# Builds a grid of hexagonal cells according to samples coordinates (columns x and y)
# using the EPSG:3857 projection and an halfwidth cell value of hw=250m.
grid <- MAPI_GridHexagonal(samples2, crs=3857, hw=250, buf=1500)
grid.var <- MAPI_Varicell(grid, samples2, buf=250, var.coef=20)
ggplot() +
geom_sf(data=grid.var, aes(fill=dens), size=0.1) +
geom_sf(data=st_as_sf(samples2, coords=c("x","y"), crs=3857), aes())
}
Run the code above in your browser using DataLab