Skip to main content

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

hms2cng logo

PyPI version ReadTheDocs MIT License

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:

  • tippecanoeconda install -c conda-forge tippecanoe
  • pmtilesgo 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

hms2cng-0.1.2.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hms2cng-0.1.2-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file hms2cng-0.1.2.tar.gz.

File metadata

  • Download URL: hms2cng-0.1.2.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for hms2cng-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1ff898146b903880ccc3cdfe078bdf87014a4e834f892a5f05040273507b7328
MD5 f64f189ec7ebd3e1f5bdc3c95470b10b
BLAKE2b-256 12997196046f49c4f83649037b9ce622fb22ce3bd1c2f4cb31e14516d8424c49

See more details on using hashes here.

File details

Details for the file hms2cng-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hms2cng-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for hms2cng-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b80a56dce18da7fcf71aa72fbe334fe157c2a60f2dc234e8b4bc145fd91ab03
MD5 83de60256067199b325b9b7474f3e7d1
BLAKE2b-256 e3ece60f944b7d5357334b73f22f5b11ad4391864bfee09da7182c12be3654db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page