HexWatershed

Runs HexWatershed watershed delineation on unstructured meshes via JSON-configured C++ binary.

155|6|Updated Mar 31, 2026
One-click install
npx skills add https://github.com/lzwei196/KISS-Knowledge-Infrastructure-for-Scientific-Simulation --skill hexwatershed-lzwei196
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: HexWatershed
Source: https://github.com/lzwei196/KISS-Knowledge-Infrastructure-for-Scientific-Simulation/tree/main/models/HexWatershed
Command: npx skills add https://github.com/lzwei196/KISS-Knowledge-Infrastructure-for-Scientific-Simulation --skill hexwatershed-lzwei196

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyflowline, pyhexwatershed, gdal, and includes scripts (resource) and references (resource) components.

What problem does it solve? Running the HexWatershed C++ watershed delineation model correctly requires deep operational knowledge: mesh JSON must match the configured mesh type, coordinates must be geographic degrees, DEM elevations must be meters, and silent failure modes (skipped outlets, ignored flowlines, unit mismatches) produce plausible-looking but wrong results. This Skill packages that expertise so an agent can build, configure, execute, and validate HexWatershed runs without falling into its documented traps. ## Core Features & Use Cases - Six-stage delineation pipeline: configuration, mesh generation via PyFlowline, flowline preparation, binary execution, output parsing to CSV/GeoJSON, and validation against reference data. - Four executable tools: mesh_converter.py, flowline_converter.py, run_hexwatershed.py, and output_parser.py, plus a preflight_check.py that verifies the binary, Python environment, and required files before any run. - 18 diagnostic triplets: a symptom-to-diagnosis-to-remedy table covering silent unit traps (feet vs meters DEM, km² vs m² cell area, ratio vs absolute accumulation thresholds) and fatal errors (projected CRS, mesh-type mismatch, nodata mismatch). - Use Case: Delineate a watershed on a hexagonal mesh from a MERIT DEM: generate the mesh with PyFlowline, build the config JSON, run the hexwatershed binary, and parse watershed_NNNNN.json into CSV with drainage area, stream order, and drainage density. ## Quick Start Run python preflight_check.py in this directory, then ask the agent to delineate a watershed from your DEM by generating a hexagon mesh with PyFlowline and executing the HexWatershed binary with a validated config JSON.

Frequently Asked Questions about HexWatershed

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run HexWatershed to delineate a watershed?

Build the C++ binary with CMake, generate a mesh JSON with PyFlowline from a GCS DEM in meters, write a config JSON with matching sMesh_type, then run hexwatershed config.json. Parse results with output_parser.py to get CSV or GeoJSON outputs.

What mesh types does HexWatershed support?

HexWatershed supports six mesh types selected via sMesh_type: hexagon, square, latlon, mpas, dggrid, and tin. The mesh JSON structure must match the configured type or the parser segfaults or misreads connectivity.

Why does HexWatershed run successfully but produce no watershed output?

The lCellID_outlet in the basin JSON does not match any cell in the mesh, so the watershed is silently skipped with exit code 0. Use flowline_converter.py with --mesh-json to auto-detect the nearest valid outlet cell ID.

Why are HexWatershed slopes or drainage densities wildly wrong?

Slopes are unitless rise-over-run ratios, not degrees, and are inflated ~3.28x if the DEM is in feet. Drainage density requires converting stream length to km and area to km²; cell areas in km² instead of m² cause 10⁶x errors.

Does HexWatershed stream burning work with raw NHD or HydroSHEDS shapefiles?

No. Stream burning requires flowlines preprocessed by PyFlowline with cell-to-stream topology mapping; raw shapefiles are silently ignored. Flowline coordinates must also be in EPSG:4326 geographic degrees to intersect the mesh.

What are the limitations of HexWatershed?

HexWatershed performs static topographic delineation only: no streamflow, rainfall-runoff, or time-evolving hydrologic state. Mesh generation is delegated to the external PyFlowline package, and flow accumulation is an area-unweighted cell count.