library(sf)
# Single support
support <- st_as_sf(
data.frame(id = 1),
geometry = st_sfc(st_polygon(list(
cbind(c(0, 10, 10, 0, 0), c(0, 0, 10, 10, 0))
))),
crs = 32631
)
pts <- st_as_sf(
data.frame(id = 1:4),
geometry = st_sfc(
st_point(c(5, 5)),
st_point(c(2, 2)),
st_point(c(15, 5)),
st_point(c(30, 30))
),
crs = 32631
)
result <- aoe(pts, support)
# Multiple supports (e.g., admin regions)
supports <- st_as_sf(
data.frame(region = c("A", "B")),
geometry = st_sfc(
st_polygon(list(cbind(c(0, 10, 10, 0, 0), c(0, 0, 10, 10, 0)))),
st_polygon(list(cbind(c(8, 18, 18, 8, 8), c(0, 0, 10, 10, 0))))
),
crs = 32631
)
result <- aoe(pts, supports)
# Points near the boundary may appear in both regions' AoE
Run the code above in your browser using DataLab