
Extract geometric measures from a shapefile object
Source:R/utils_shapefile.R
shapefile_measures.Rd
shapefile_measures()
calculates key geometric measures such as the number
of points, area, perimeter, width, height, and centroid coordinates for a
given shapefile (polygon) object.
Value
A modified sf
object with added columns for:
xcoord
: The x-coordinate of the centroid.ycoord
: The y-coordinate of the centroid.area
: The area of the polygon (in square units).perimeter
: The perimeter of the polygon (in linear units).width
: The calculated width based on sequential distances between points. The result will only be accurate if the polygon is rectangular.height
: The calculated height based on sequential distances between points. The result will only be accurate if the polygon is rectangular.
Details
This function processes a single or multi-polygon sf
object and computes
geometric properties. It calculates distances between points, extracts the
centroid coordinates, and computes the area and perimeter of the polygons.
The width and height are derived from sequential distances between points.
Examples
if (interactive() && requireNamespace("EBImage")) {
library(pliman)
path_shp <- paste0(image_pliman(), "/soy_shape.rds")
shp <- shapefile_input(path_shp)
shapefile_measures(shp)
}