egvtools: High-resolution Ecogeographical Variable Workflows
Source:R/egvtools-package.R
egvtools.Rd
egvtools
provides a coherent set of wrappers and utilities that make
large-scale EGV creation reproducible and pleasant on real datasets.
The package leans on robust building blocks—terra
, sf
, sfarrow
,
exactextractr
, and whitebox
—and standardizes I/O, naming conventions,
and multi-scale zonal statistics so your pipelines are repeatable across machines
and projects.
Core workflow (generalizable)
Functions that form the backbone of your analyses (thin wrappers over existing libs, but opinionated for stability, speed and consistency):
polygon2input()
— rasterize polygons to template, handle background/mask.downscale2egv()
— downscale coarse rasters to template grid and optionally smooth with IDW.distance2egv()
— distances to features with optional gap filling at the edges.input2egv()
— normalize/align inputs to EGV outputs with guards.landscape_function()
— landscapemetrics landscape-level per-zone metrics, tiled.radius_function()
— multi-scale zonal statistics (dense/sparse).tile_vector_grid()
— tile template grids for chunked processing.tiled_buffers()
— precompute buffered tiles for multiple radii.create_backgrounds()
— build consistent background rasters/values.
Reproducibility helpers
Utilities that set up inputs and structure so our (project HiQBioDiv) results can be reproduced:
download_raster_templates()
— fetch template rasters (Zenodo) to canonical paths.download_vector_templates()
— fetch template vector grids/points.
Design principles
Tiled, RAM-aware I/O; workers open data by path (avoid big globals) and caches them if necessary (avoid big I/O).
Deterministic filenames and strict layer/radius naming.
Guards for empty/invalid geometries, coordinate reference systems, naming and all-NA joins.
Cross-platform parallel via
{future}/{furrr}
when enabled.
Options
Package defaults are set on load (see zzz-options.R
). Users may override:
options(egvtools.future_plan = "sequential")
options(egvtools.progress = TRUE)
egvtools.future_plan
: default parallel plan name (e.g."sequential"
,"multisession"
).egvtools.progress
: logical, show progress bars (TRUE
/FALSE
).
Getting started
Run
download_*_templates()
to fetch canonical inputs.Use
tile_vector_grid()
/tiled_buffers()
for scalable chunks.Produce EGVs at site scale with
polygon2input()
,downscale2egv()
,distance2egv()
,input2egv()
, and summarise from larger scales withlandscape_function()
/radius_function()
.
See also
Useful links:
GitHub repo: https://github.com/aavotins/egvtools
Package site: https://aavotins.github.io/egvtools/
Issues / bugs: https://github.com/aavotins/egvtools/issues
Author
Maintainer: Andris Avotiņš andris.avotins@lu.lv