Generate an inner boundary polygon by shrinking an existing boundary inward
Source:R/GetBoundary.R
GetInnerBoundary.RdComputes an inward-shifted (contracted) boundary by applying a
negative spatial buffer to an existing boundary polygon.
This function is a wrapper around getOuterBoundary() and is useful
for defining an inner region around a spatial cluster or structure.
Details
Be careful: if the shrinkage distance is too large, the resulting geometry may become invalid or disappear entirely, especially for narrow or irregular shapes.
See also
getOuterBoundary() for the outward (positive) buffer version.
Examples
# Load coordinates
coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds",
package = "SpNeigh"
))
# Get boundary polygons of cluster 2
boundary_points <- getBoundary(data = coords, one_cluster = 2)
boundary_polys <- buildBoundaryPoly(boundary_points)
plot(boundary_polys)
# Generate inner boundary with 50-unit buffer for boundary region 1
inner_boundary <- getInnerBoundary(boundary_polys)
#> Warning: Some inner boundaries may have collapsed or disappeared due to excessive shrinkage.
plot(inner_boundary)