CLI for exporting HEC-RAS geometry/results to cloud-native GIS formats (GeoParquet, PMTiles, DuckDB, PostGIS)
Project description
ras2cng — RAS to Cloud Native GIS
CLI tool for exporting HEC-RAS geometry and results to cloud-native GIS formats: GeoParquet, DuckDB, PMTiles, and PostGIS.
Built on ras-commander for HEC-RAS file parsing.
Installation
# Core (geometry + results export)
pip install ras2cng
# All optional extras (DuckDB analytics, PostGIS sync, PMTiles rasterio)
pip install "ras2cng[all]"
# Individual extras
pip install "ras2cng[duckdb]" # DuckDB SQL analytics
pip install "ras2cng[postgis]" # PostGIS sync
pip install "ras2cng[pmtiles]" # rasterio (PMTiles also needs tippecanoe + pmtiles CLIs)
Quick Start
# Export mesh cell geometry from HDF
ras2cng geometry model.g01.hdf mesh_cells.parquet --layer mesh_cells
# Export max depth results joined to polygon geometry
ras2cng results model.p01.hdf max_depth.parquet \
--geometry mesh_cells.parquet --var "Maximum Depth"
# Query with DuckDB (use _ as table name)
ras2cng query max_depth.parquet \
"SELECT mesh_name, AVG(maximum_depth) FROM _ GROUP BY mesh_name"
# Generate PMTiles (requires tippecanoe + pmtiles on PATH)
ras2cng pmtiles max_depth.parquet flood_depth.pmtiles --layer flood --min-zoom 8 --max-zoom 14
# Sync to PostGIS
ras2cng sync max_depth.parquet "postgresql://user:pass@host/db" max_depth --schema hydraulics
Python API
from ras2cng import (
export_geometry_layers,
export_results_layer,
export_all_variables,
DuckSession,
query_parquet,
generate_pmtiles_from_input,
sync_to_postgres,
)
from pathlib import Path
# Export geometry
export_geometry_layers(Path("model.g01.hdf"), Path("mesh_cells.parquet"), layer="mesh_cells")
# Export results joined to polygon geometry
export_results_layer(
plan_hdf=Path("model.p01.hdf"),
output=Path("max_depth.parquet"),
variable="Maximum Depth",
geom_file=Path("mesh_cells.parquet"),
)
# DuckDB query (table alias is always _)
df = query_parquet(Path("max_depth.parquet"), "SELECT * FROM _ WHERE maximum_depth > 3.0")
# Advanced DuckDB session with spatial
with DuckSession() as duck:
duck.register_parquet("max_depth.parquet")
df = duck.query("SELECT mesh_name, MAX(maximum_depth) FROM _ GROUP BY mesh_name")
Extractable Data
Geometry Layers
| Layer | Geometry | Source |
|---|---|---|
mesh_cells |
Polygon (Point fallback) | HDF geometry only (*.g??.hdf) |
cross_sections |
LineString | HDF geometry + text geometry (*.g??) |
centerlines |
LineString | HDF geometry + text geometry |
Results Variables
Exported from plan HDF files (*.p??.hdf). Common 2D mesh summary variables:
Maximum Depth→maximum_depthMaximum Water Surface→maximum_water_surfaceMaximum Velocity→maximum_velocity
Column names are snake_case (ras-commander normalization). Use --all to export every available variable.
Output Formats
| Format | Command | Requirements |
|---|---|---|
| GeoParquet | geometry, results |
Built-in |
| DuckDB SQL | query |
pip install "ras2cng[duckdb]" |
| Vector PMTiles | pmtiles |
tippecanoe + pmtiles CLIs |
| Raster PMTiles | pmtiles |
gdal_translate + pmtiles CLIs |
| PostGIS | sync |
pip install "ras2cng[postgis]" |
External CLIs for PMTiles
# via conda-forge
conda install -c conda-forge tippecanoe pmtiles
Or download from felt/tippecanoe and protomaps/go-pmtiles.
Documentation
Full documentation: https://gpt-cmdr.github.io/ras2cng/
License
MIT License — see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ras2cng-0.1.0.tar.gz.
File metadata
- Download URL: ras2cng-0.1.0.tar.gz
- Upload date:
- Size: 276.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa3548a79da27bed437b632551ec26f0e6773279ca5e142d095fc4d63063566e
|
|
| MD5 |
484419a6b018c4e7d81f67a28b0fbc58
|
|
| BLAKE2b-256 |
e441554e6ee4a438f613917da1baf4859f1e19dbf0a80a5257da77570a7f707a
|
File details
Details for the file ras2cng-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ras2cng-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78571cfd79477f277a00ae7e9f9dbbc00767fe227a13c003692865d99b41a122
|
|
| MD5 |
f96c603b86e9d40865702749a78f1ea9
|
|
| BLAKE2b-256 |
a9eb78c3eaa7b64e02644f4312dec73ec3375f95673543f8604868b6dd303166
|