| geomattR-package | R Documentation |
Calculate geometric attributes of spatial polygons. Computes area, perimeter, compactness, elongation, orientation, fractal dimension, and shape indices suitable for geospatial analysis, urban planning, and environmental science applications.
By default, measurements use geodesic calculations for accuracy across
large study regions (i.e. continental scale studies). The package supports the
"geo", "haversine", and "cosine" methods and
automatically handles geographic (lon/lat) and projected CRS appropriately.
calculate_geometric_attributes(): Calculate metrics for one or more
polygons. Runs sequentially by default; pass a cl argument for parallel
execution.
get_distant_points(): Find most distant points on convex hull
calc_elongation(): Calculate elongation ratio
calc_extent(): Calculate east-west and north-south extents
All calculations prioritize accuracy:
Area & Perimeter: Geodesic by default; projected input is handled transparently for methods that need geographic coordinates
Distances: Support method = "geo", "haversine", and "cosine".
All three are lon/lat great-circle methods; on a projected CRS,
terra::distance() ignores method and computes Cartesian distances
Bearing: Computed from geographic coordinates when needed
Automatic Projection: Non-geographic CRS are handled transparently
Precise definitions of each reported metric are documented in
calculate_geometric_attributes().
library(geomattR)
library(terra)
# Create sample polygon in WGS84
coords <- cbind(c(0, 0, 1, 1, 0), c(0, 1, 1, 0, 0))
polygon <- vect(coords, type = "polygon", crs = "EPSG:4326")
# Calculate all attributes (geodesic by default)
result <- calculate_geometric_attributes(polygon)
# Calculate specific metrics
result <- calculate_geometric_attributes(polygon,
metrics = c("area", "perimeter", "compactness"))
# Parallel processing
cl <- parallel::makeCluster(2)
result <- calculate_geometric_attributes(polygon, cl = cl)
parallel::stopCluster(cl)
This package began as a side project during my time as a technician on BEAST – BiodivErsity dynamics Across a continuum of Space, Time, and their scales, led by Petr Keil, and was therefore partially funded by the European Union (ERC, BEAST, grant no. 101044740). Views and opinions expressed are those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Council Executive Agency; neither the European Union nor the granting authority can be held responsible for them.
Discussions with P. Keil on spatial and geometric problems inspired the package. G. Ortega-Solís developed all core functions; Claude Code was used to double-check the code and to help write unit tests.
Maintainer: Gabriel Ortega-Solís g.ortega.solis@geomattr.org (ORCID) [copyright holder]
Authors:
Gabriel Ortega-Solís g.ortega.solis@geomattr.org (ORCID) [copyright holder]
Useful links:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.