View source: R/utils_shapefile.R
shapefile_measures | R Documentation |
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.
shapefile_measures(shapefile, n = NULL)
shapefile |
An |
n |
An integer specifying the number of polygons to process. If |
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.
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.
if (interactive() && requireNamespace("EBImage")) {
library(pliman)
path_shp <- paste0(image_pliman(), "/soy_shape.rds")
shp <- shapefile_input(path_shp)
shapefile_measures(shp)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.