Skip to contents

Hydrofabric I/O

Read and write hydrofabric layers from GeoPackages, and lazily query any GDAL/OGR vector source with dplyr.

read_hydrofabric()
Read Hydrofabric Layers from a GeoPackage (or accept in-memory `sf` objects)
write_hydrofabric()
Write a hydrofabric GeoPackage (mixed sf + non-sf)
as_ogr()
Delayed read for vector resources
layer_exists()
Check if a layer exists in a geopackage
OGRSQL()
OGRSQL OGRSQL driver, use to [dbConnect()] to a data source readable by sf
gpkg_exec()
Run arbitrary SQL against a GeoPackage in a single transaction
gpkg_update_col()
In-place update of a single non-geometry column in a GeoPackage layer
gpkg_update_geom()
In-place geometry update for specific rows of a GeoPackage layer

Cloud & GeoParquet

Authenticated cloud access and GeoParquet/Arrow round-trips for sf objects.

lynker_spatial_auth()
Authenticate with Lynker Spatial
lynker_spatial_token()
Get an OAuth2 token for Lynker Spatial
lynker_spatial_refresh()
Refresh an existing Lynker Spatial token
duckdb_connection()
Create a new DuckDB connection
tbl_http()
Read DuckDB File(s) over HTTP
st_read_parquet()
Read a Parquet file to sf object
st_write_parquet()
Write sf object to Parquet file
read_sf_dataset()
Read Parquet Dataset
write_sf_dataset()
Write Parquet Dataset

Geometry cleaning

Repair and simplify DEM-derived catchment geometry, and fast unions by ID.

clean_geometry()
Clean Catchment Geometry
clean_gpkg_layer()
Clean polygon topology in a GeoPackage layer using GDAL and Mapshaper
union_polygons()
Dissolve polygons by ID
union_linestrings()
Fast linestring union by ID
flowpaths_to_linestrings()
Convert MULTILINESTRINGS to LINESTRINGS

Network & topology

Algorithms over the directed (DAG) flow network.

accumulate_downstream()
Accumulate an attribute downstream over a directed acyclic network
get_hydroseq()
Compute and add the hydrosequence to a directed acyclic network
get_streamorder()
Compute and add Strahler stream order to a directed acyclic network
get_levelpath()
Compute mainstem level paths over a directed acyclic network
get_pathlength()
Compute downstream path length to the network outlet over a DAG
get_streamlevel()
Compute stream level over a directed acyclic network
get_pfafstetter()
Compute Pfafstetter basin codes over a directed acyclic network
upstream_index()
Nested-set upstream index over a rooted-tree network
hf_upstream_index()
Nested-set upstream index for a hydrofabric (flowpath + nexus grain)
merge_groups()
Group a network into contiguous same-order runs for partitioning
add_measures()
Add length and area measures to flowpaths/divides
add_areasqkm()
Compute area in square kilometers (numeric)
add_lengthkm()
Compute length in kilometers (numeric)
get_node()
Get endpoint or startpoint of LINESTRING
node_geometry()
Node geometry from line endpoints
rename_geometry()
Rename geometry column of sf object
hf_network_is_dag()
Is a flowpath network a directed acyclic graph?
hf_assert_network_dag()
Assert a flowpath network is a DAG, reporting any cycle nodes
hf_recompute_hydroseq()
Recompute hydrosequence for a flowpath network by topological sort
hf_break_cycles()
Break cycles in a flowpath network by severing one back-edge per SCC
hf_fmt_id()
Format numeric identifiers without scientific notation

QGIS styling

Stamp the packaged QGIS symbology into a GeoPackage so it opens pre-styled.

append_style()
Write QGIS layer styles into a GeoPackage
read_qml()
Read a QML style file
create_style_row()
Build one `layer_styles` row for a GeoPackage layer

Versioning & quality assurance

Stamp dataset versions and provenance into GeoPackages, and run staged pipeline invariant checks shared across the stack.

gpkg_set_version()
Stamp a dataset version into a GeoPackage's metadata tables
gpkg_get_version()
Read the dataset version written by [gpkg_set_version()]
hf_check_invariants()
Pipeline invariant checks
hf_check_merge_invariants()
Global-merge (Stage 4) conservation + completeness invariants
hf_check_attr_bounds()
Check divide/flowpath attribute values against physical-range bounds
hf_attr_bounds()
Physical-range bounds for divide and flowpath attributes

DBI / OGR-SQL backend

Low-level S4 classes and methods backing the lazy as_ogr() interface.