Skip to main content

hms2cng — HMS to Cloud Native GIS

hms2cng logo

PyPI version Documentation 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: rascommander.info/hms2cng

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

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.2.0.tar.gz (46.3 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.2.0-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hms2cng-0.2.0.tar.gz
  • Upload date:
  • Size: 46.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for hms2cng-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f7a8f086915812b5df81388d7f47342f76662d8c003d39f3908b5922e37613a0
MD5 c426299eaf58759f6f0b0aa7813f18bd
BLAKE2b-256 d94bdf5a9ce5dbe7fc6eb04b881295f4d1e32e0a06bb4f3597db4e58eef8c3aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hms2cng-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for hms2cng-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16399a5fc413ee09761c3bcd67b0f0e2f9e4404b7271c926682c6ff1f74b3e81
MD5 4901c89a8a11a15923e167a690c852c0
BLAKE2b-256 6fcc576f5f53ddc4108aaf8431396a0d6ee8cb826392bd9ee67d45b830fcc3c2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page