library(sf)
# Create a support with sparse points
support <- st_as_sf(
data.frame(id = 1),
geometry = st_sfc(st_polygon(list(
cbind(c(0, 100, 100, 0, 0), c(0, 0, 100, 100, 0))
))),
crs = 32631
)
# Points scattered around
set.seed(42)
pts <- st_as_sf(
data.frame(id = 1:50),
geometry = st_sfc(lapply(1:50, function(i) {
st_point(c(runif(1, -50, 150), runif(1, -50, 150)))
})),
crs = 32631
)
# Expand until we have at least 20 points
result <- aoe_expand(pts, support, min_points = 20)
# Check expansion info
attr(result, "expansion_info")
Run the code above in your browser using DataLab