Skip to content

spatcovar

0.1.0Package record

Construct Spatial Covariates from Polygon Data

0packages depend
559downloads / year
73.3%test coverage
13/13flavors OK

Overview

About

Provides a consistent interface for constructing commonly used spatial covariates from polygon data. Computes polygon areas, distances to reference features, point and line intersection counts, line lengths within polygons, polygon overlap areas and shares, and raster zonal summaries. Handles coordinate reference system validation, geometry repair, unit conversion, row preservation, and standardised missing value semantics while relying on established spatial libraries for the underlying geometry operations.

Changes in 0.1.0

Initial release of spatcovar, an R package providing a consistent, pipeable

interface for constructing commonly used spatial covariates directly on sf

polygon data frames.

Core Functions

  • 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".
Show all changes in 0.1.0Hide the rest of the changes in 0.1.0
  • 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.

Synthetic Example Datasets

  • Provides five lightweight, self-contained synthetic fixtures in EPSG:32632 for examples, testing, and reproducible workflows without external file dependencies: example_polygons(), example_points(), example_lines(), example_grid(), and example_raster().

Design Guarantees & Semantics

  • **Row and Geometry Preservation**: Output data frames retain the exact row count, row order, and original geometry of the input target polygons.
  • **Safe Geometry Repair**: Invalid geometries are repaired on internal copies used for computation (repair = TRUE by default); the geometry column returned to the user is never altered.
  • **Coordinate Reference System Policy**: Enforces strict validation requiring known coordinate reference systems on all vector and raster inputs. spat_length() strictly requires a projected (planar) CRS.
  • **Dynamic Output Column Naming**: Derives deterministic, unit-aware column names by default (e.g. area_km2, dist_m, length_km, overlap_share), with user override via the name argument.
  • **Collision Protection**: Prevents accidental overwriting of existing data frame columns unless explicitly allowed with overwrite = TRUE.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 2.2 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OKNow
  • OK6 OK2026-09-09
Advisories

none known

Documentation

In release 0.1.0
READMEYes · 328 wordsVignettesYes · 1 · dynamicNEWSYes · 67% structured · mentions 0.1.0Citation fileYes · software entry onlyWebsitenot declared in DESCRIPTION
Help pages
13 (1 internal)includes a package overview page
Examples that run
100%12 run in a plain check
Exported functions with examples
100%
Documented parameters
100%
Return-value docs
100%
Help pages citing references
0%

Downloads

559
CRAN downloads in the past year
Rank #23,253 · ~2/day · ~47/mo
Daily download trend is not available in this view yet.
31630 days
55990 days
5591 year
Compare downloads with other packages →
Also on6 r2u1 autocran

Repository

1Stars
0Forks
0Open issues
0Open PRs
1Releases
3Commits
1Commit identities
geospatialrsfspatialspatial-analysis
3 commits · Last activity 2026-09-26
Responsiveness
not measured

Stars over time

2026-09-09 · 02026-09-27 · 1
PracticesBeta

6 development-tooling and community-health practices detected across 5 families in the upstream repository

Checks run against github.com/emre-cebeci/spatcovar on 2026-10-21.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Governance and community (1)
Contributing guide
Coverage (1)
Coverage reporting
CRAN release process (1)
cran-comments.md
Show all practicesHide 1 practice
Research and citation (1)
CITATION.cff
How this is detected·Detection ruleset v4 (2026-10-20)

Dependencies

Declared dependencies
8 external dependencies (excludes base and recommended)

Installing spatcovar adds 13 packages (12 with compiled code, 24 MB of source tarballs). Heaviest: sf 9.3 MB, sp 4.3 MB, s2 2.8 MB.

Depends (0)
none
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

People & History

People (1)
Author, Maintainer since 0.1.0 (2026)
Releases (1)
  • 0.1.0Latest
    2026-09-08 · current release
  • R
    R 4.6.0 released · 2026-04-24

Package metadata

First published
2026-09-08
Total releases
1 / 1 yrs
License
MIT + file LICENSE OSI
Download size
43 KB

Cite

Cite this package

Run in R for the authors' entry:

citation("spatcovar")

The package provides a citation file, so citation() returns the authors' own entry.

The repository also keeps a CITATION.cff.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for spatcovar version 0.1.0 [Data set]. HJJB, LLC. Data release v2026-10-23. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-23, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy