Constructs spatial polygon objects from boundary points generated by
the getBoundary() function.
Each set of boundary points (grouped by region_id) is converted
into a closed polygon.
This function ensures that each polygon is valid and ready for
downstream spatial analysis.
Arguments
- boundary
A data frame of boundary points, typically returned by
getBoundary(). Must contain columnsx,y, andregion_id.
Examples
# Load coordinates
coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds",
package = "SpNeigh"
))
# Get boundary points for cluster 2
boundary_points <- getBoundary(data = coords, one_cluster = 2)
# Convert to polygon
boundary_polys <- buildBoundaryPoly(boundary_points)
# Plot the resulting polygons
plot(boundary_polys)