HMS to Cloud Native GIS — CLI for exporting HEC-HMS results to GeoParquet, PMTiles, DuckDB, and PostGIS
Project description
hms2cng — HMS to Cloud Native GIS
Full project access and archival for HEC-HMS. Exports geometry, simulation results, and project metadata to cloud-native GeoParquet — enabling cross-project DuckDB analytics, PMTiles web visualization, and PostGIS integration.
Documentation: hms2cng.readthedocs.io
Built on top of hms-commander by CLB Engineering Corporation.
Installation
# Base installation (GeoParquet export only)
pip install hms2cng
# All features (DuckDB, PostGIS, PMTiles)
pip install "hms2cng[all]"
PMTiles Generation
PMTiles generation requires external CLI tools:
- tippecanoe —
conda install -c conda-forge tippecanoe - pmtiles —
go install github.com/protomaps/go-pmtiles/pmtiles@latest
Quick Start
Full Project Export
Export an entire HMS project — all basin models, all runs, all layers:
# Preview the project structure (runs, basin models, met models)
hms2cng manifest MyProject.hms
# Export everything to a hierarchical GeoParquet archive
hms2cng project MyProject.hms out/my_archive/
Output structure:
out/my_archive/
manifest.parquet # project-level metadata (1 row)
run_registry.parquet # basin + met + control lineage per run
basin_inventory.parquet # element counts per basin model
geometry/
{basin_slug}/
subbasins.parquet
reaches.parquet
junctions.parquet
...
results/
{run_slug}/
outflow.parquet # peak, min, mean, time of peak
Query across all runs with DuckDB:
import duckdb
df = duckdb.sql("""
SELECT project_name, run_name, name, max_value, units
FROM read_parquet('out/my_archive/results/*/*.parquet', union_by_name=true)
ORDER BY max_value DESC
LIMIT 20
""").df()
Single-Layer Export
# Export a specific geometry layer
hms2cng geometry model.basin subbasins.parquet --layer subbasins
# Export simulation results
hms2cng results project/results results.parquet --type subbasin --var Outflow
# Query with DuckDB
hms2cng query results.parquet "SELECT name, max_value FROM _ ORDER BY max_value DESC"
# Generate PMTiles (requires tippecanoe + pmtiles)
hms2cng pmtiles subbasins.parquet subbasins.pmtiles --layer subbasins
# Sync to PostGIS
hms2cng sync subbasins.parquet "postgresql://user:pass@host:5432/db" hms_subbasins
Python API
from hms2cng import (
export_full_project, # export entire HMS project
get_project_manifest, # read project structure as dict
export_all_basin_geometry, # batch geometry export
export_all_results, # batch results export
export_basin_geometry, # single layer export
export_hms_results, # single run export
DuckSession,
)
# Full project archive
summary = export_full_project("MyProject.hms", "out/archive/")
print(f"Geometry files: {len(summary['geometry_files'])}")
print(f"Results files: {len(summary['results_files'])}")
# Project manifest
manifest = get_project_manifest("MyProject.hms")
print(manifest["run_names"]) # JSON list of run names
# Single layer (original API unchanged)
from hms2cng.geometry import get_basin_layer_gdf
gdf = get_basin_layer_gdf("project.basin", layer="subbasins")
Cloud Native GIS Stack
| Legacy | Cloud Native | Benefit |
|---|---|---|
| Shapefile | GeoParquet | Columnar, Arrow-native, compressed |
| WMS/WFS | PMTiles | Serverless HTTP range requests |
| PostGIS queries | DuckDB | In-process spatial SQL, no server |
| SDE layers | PostGIS | Open standard, cloud-ready |
Development
git clone https://github.com/gpt-cmdr/hms2cng
cd hms2cng
uv pip install -e ".[all]"
# Run tests
uv run pytest tests/
# Interactive examples (marimo)
uv run marimo edit examples/06_full_project_export.py
# Preview docs
uv run mkdocs serve
About CLB Engineering
hms2cng is an open-source project of CLB Engineering Corporation, the creators of hms-commander and ras-commander.
CLB pioneered the LLM Forward approach to civil engineering — a framework where licensed professional engineers leverage Large Language Models to accelerate H&H modeling workflows while maintaining full professional responsibility.
Contact: info@clbengineering.com | Website: clbengineering.com
License
MIT — See LICENSE
Author: William M. Katzenmeyer, P.E., C.F.M. — CLB Engineering Corporation
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 hms2cng-0.1.3.tar.gz.
File metadata
- Download URL: hms2cng-0.1.3.tar.gz
- Upload date:
- Size: 39.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
052b620f2e93386e5ecd2bdd81f2000c9358b38a8660284420c399979b2bc740
|
|
| MD5 |
590b06f5016e68f03b7e850bfdc2d95f
|
|
| BLAKE2b-256 |
3cb214972324e804ace42f2796291146338f10e9c968af7681c819277c1c60e8
|
File details
Details for the file hms2cng-0.1.3-py3-none-any.whl.
File metadata
- Download URL: hms2cng-0.1.3-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb27c5d58eac455982e84e4a51e35b165c8566b4c38703f3f3f1606bebc1d1c0
|
|
| MD5 |
39e39b6a3f3ae0980dd470ec0faf31ba
|
|
| BLAKE2b-256 |
83dcd69b04b78c23425f3301a02210fb926eee10f5eba52cf2986d860014b19b
|