shapefile_measures: Extract geometric measures from a shapefile object
Description
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.
Usage
shapefile_measures(shapefile, n = NULL)
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.
Arguments
shapefile
An sf object representing the shapefile. It should contain
polygonal geometries for which the measures will be calculated.
n
An integer specifying the number of polygons to process. If NULL,
all polygons are considered.
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.