spatcovar provides a consistent interface for
constructing commonly used spatial covariates from polygon data. It
computes polygon areas, distances to reference features, intersection
counts, line lengths within polygons, polygon overlap areas and shares,
and raster zonal summaries while handling coordinate reference system
validation, geometry repair, unit conversion, row preservation, and
standardised missing-value semantics.
spatcovar builds on established spatial engines (sf, terra, exactextractr)
rather than reimplementing the underlying geometry operations.
Install the development version from GitHub:
# install.packages("pak")
pak::pak("emre-cebeci/spatcovar")library(spatcovar)
regions <- example_polygons()
sites <- example_points()
routes <- example_lines()
zones <- example_grid()
rst <- example_raster()
# Build several covariates in a pipeline
result <- regions |>
spat_area(unit = "km2") |>
spat_count(sites, name = "n_sites") |>
spat_length(routes, unit = "km") |>
spat_distance(sites, name = "dist_to_sites") |>
spat_overlap(zones, measure = "share") |>
spat_raster(rst, stats = c("mean", "max"), name = "elev")
result| Function | Description |
|---|---|
spat_area() |
Polygon area with unit conversion |
spat_distance() |
Distance to reference features (minimum, centroid, or point-on-surface) |
spat_count() |
Count of source features intersecting each polygon |
spat_length() |
Total length of line features within each polygon |
spat_overlap() |
Overlap area, target-area share, or intersecting-feature count |
spat_raster() |
Zonal raster statistics (mean, median, min, max, sum, count, stdev) |
spat_diagnostics() |
Retrieve operation diagnostics from a result |
spat_area(), spat_distance(),
spat_overlap()) use geodesic measurement on geographic CRS
(via sf/s2). An optional crs argument is provided when
user-selected planar projection is desired.spat_length()) strictly
requires a projected CRS for planar clipping and measurement (either on
the input data or supplied via the crs argument).spat_count(), spat_raster()) validate
coordinate reference systems and align source layers internally.When repair = TRUE (the default), invalid geometries are
repaired on internal copies used for computation. The geometry returned
to the user is always the original target geometry.
spatcovar does not
dospatcovar is a focused package for constructing common
spatial covariates from polygon data. It does not provide general GIS
manipulation, mapping, geocoding, boundary harmonization, persistent
spatial identifiers, areal interpolation methodology, raster processing
pipelines, or causal inference tools.
MIT
Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.
This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.