| aoe_expand | R Documentation |
Expands the area of effect just enough to capture at least min_points,
subject to hard caps on expansion. This is useful when a fixed scale leaves
some supports with insufficient data for stable modelling.
aoe_expand(
points,
support = NULL,
min_points,
max_area = 2,
max_dist = NULL,
method = c("buffer", "stamp"),
reference = NULL,
mask = NULL,
coords = NULL
)
points |
An |
support |
One of:
|
min_points |
Minimum number of points to capture in the AoE. The function finds the smallest scale that includes at least this many points. |
max_area |
Maximum halo area as a proportion of the original support area.
Default is 2, meaning halo area cannot exceed twice the support area
(total AoE <= 3x original). Set to |
max_dist |
Maximum expansion distance in CRS units. For the buffer method,
this is the maximum buffer distance. For the stamp method, this is converted
to a maximum scale based on the support's characteristic radius.
Default is |
method |
Method for computing the area of effect:
|
reference |
Optional If |
mask |
Optional mask for clipping the area of effect. Can be:
|
coords |
Column names for coordinates when |
Unlike aoe(), which applies consistent geometry across all supports,
aoe_expand() adapts the scale per-support based on local point density.
Use with caution: this can make AoEs incomparable across regions with
different point densities.
For each support, binary search finds the minimum scale where point count >= min_points. The search is bounded by:
Lower: scale = 0 (core only)
Upper: minimum of max_area cap and max_dist cap
If the caps prevent reaching min_points, a warning is issued and the result uses the maximum allowed scale.
Two caps ensure AoE doesn't expand unreasonably:
max_area (relative): Limits halo area to max_area times the original.
The corresponding scale is sqrt(1 + max_area) - 1.
Default max_area = 2 means scale <= 0.732 (total area <= 3x).
max_dist (absolute): Limits expansion distance in CRS units.
For buffer method, this is the buffer distance directly.
For stamp method, converted to scale via max_dist / characteristic_radius
where characteristic_radius = sqrt(area / pi).
An aoe_result object (same as aoe()) with additional attributes:
Logical: was min_points achieved for all supports?
Use attr(result, "expansion_info") for per-support details.
Data frame with per-support expansion details: support_id, scale_used, points_captured, target_reached, cap_hit.
aoe() for fixed-scale AoE computation
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.