Initial release of spatcovar, an R package providing a consistent, pipeable
interface for constructing commonly used spatial covariates directly on sf
polygon data frames.
spat_area(): Calculates polygon geometric areas with conversion across
metric and customary area units ("m2", "km2", "ha", "mi2").
Uses geodesic measurement on geographic coordinate reference systems (via
sf/s2) and planar measurement on projected systems.spat_distance(): Computes shortest geometry-to-geometry ("minimum"),
centroid-to-feature ("centroid"), or interior point-on-surface
("point_on_surface") distances from target polygons to reference features.
Employs indexed nearest-feature search to avoid computing full pairwise
distance matrices. Supports output in "m", "km", and "mi".spat_count(): Counts source points, lines, or polygons intersecting each
target polygon using explicit topological intersection semantics (including
boundary-touching features). Multi-geometry features count as single source
features.spat_length(): Clips line features to polygon boundaries and measures total
linework length per polygon. Explicitly handles native linear units of the
projected coordinate reference system before converting to the requested unit
("m", "km", "mi").spat_overlap(): Evaluates spatial overlap between target and source polygon
layers, returning total overlap area (measure = "area"), coverage fraction
relative to target area (measure = "share"), or intersecting polygon counts
(measure = "count"). Issues an informative warning when source polygons have
positive-area duplicate coverage among themselves.spat_raster(): Computes coverage-fraction-weighted zonal summary statistics
("mean", "median", "min", "max", "sum", "count", "stdev") from
single-layer raster grids using the exactextractr engine. Preserves valid
zero values and returns NA across all requested statistics when a polygon
has zero valid non-NA raster cell support.spat_diagnostics(): Retrieves structured operation metadata attached when
diagnostics = TRUE is passed to any core function.example_polygons(), example_points(), example_lines(),
example_grid(), and example_raster().repair = TRUE by default); the geometry column
returned to the user is never altered.spat_length() strictly requires a projected (planar) CRS.area_km2, dist_m, length_km, overlap_share),
with user override via the name argument.overwrite = TRUE.