Automated summary
Provides ras_commander-based Python recipes for reading and editing HEC-RAS plain-text geometry files (.g##): cross sections, storage areas, bridges, culverts and 2D Manning's n tables.
Strengths
- Copy-paste snippets to list, read and rewrite cross sections, with automatic .bak backup on write
- Covers several geometry entities: XS station-elevation, bank stations, storage areas, bridge decks and piers, 2D land cover
- Points to the implementation guide and example notebooks (201_1d, 202_2d) for algorithms and full API details
- Handles bank-station interpolation when writing a modified profile back
Limitations
- Relies on the external ras_commander package and its API; no raw parser code is included
- The reference is partially truncated here: the culvert and lateral structure sections cut off, so only usage patterns are shown
- Allowed tools (Read, Grep, Glob) cannot run the Python or validate the edits
Use it to inspect or bulk-edit .g## geometry in a HEC-RAS model, such as querying station-elevation profiles or updating 2D roughness values.
Avoid it for HEC-RAS project, flow or plan files, or for running the model — this skill only touches plain-text geometry.
Security analysis
SafeThe skill provides domain-specific Python code snippets for parsing and modifying HEC-RAS geometry files using a local library. It does not instruct destructive actions, exfiltration, obfuscation, or use of network/curl/sh. File modifications are legitimate engineering tasks with automatic backups. Declared allowed-tools are read-only, and the code examples are instructional rather than executed directly by the agent, further reducing risk.
No concerns found
How this analysis is madeExamples
List every cross section in model.g01 for the Ohio River / Reach 1, then show the bank stations for RS 1000.Read the station-elevation profile for RS 1000 in model.g01, lower elevations by 2 ft between stations 100 and 200, and write it back keeping the existing bank stations.Open model.g01, set Manning's n for land cover ID 42 to 0.15, and save it with a backup.name: parsing-hecras-geometry allowed-tools: [Read, Grep, Glob] description: | Parses and modifies HEC-RAS plain text geometry files (.g##) using fixed-width FORTRAN format. Handles cross sections, storage areas, bridges, culverts, lateral structures, and Manning's n tables. Use when reading geometry files, modifying cross sections, updating roughness, extracting structure data, parsing .g## files, working with XS station-elevation data, or analyzing bridge/culvert geometry. Keywords: parse, geometry, .g##, cross section, XS, Manning's n, bridge, culvert, storage, fixed-width, lateral structure, inline weir, 2D land cover, bank stations.
Parsing HEC-RAS Geometry Files
Primary Sources (navigate to these for details):
- Implementation guide:
ras_commander/geom/AGENTS.md(parsing algorithms, API reference) - Working examples:
examples/201_1d_plaintext_geometry.ipynbandexamples/202_2d_plaintext_geometry.ipynb(comprehensive demonstrations)
This skill provides quick-reference patterns for common tasks. For implementation details, parsing algorithms, and complete API documentation, see the primary sources above.
Quick Start Patterns
List Cross Sections
from ras_commander.geom.GeomCrossSection import GeomCrossSection
# List all cross sections in file
xs_df = GeomCrossSection.get_cross_sections("model.g01")
# Returns: DataFrame with River, Reach, RS, NodeName
# Filter by river/reach
xs_df = GeomCrossSection.get_cross_sections(
"model.g01",
river="Ohio River",
reach="Reach 1"
)
Read Cross Section Geometry
# Get station-elevation profile
df = GeomCrossSection.get_station_elevation(
"model.g01",
"Ohio River",
"Reach 1",
"1000"
)
# Returns: DataFrame with Station, Elevation columns
# Get bank stations
banks = GeomCrossSection.get_bank_stations(
"model.g01",
"Ohio River",
"Reach 1",
"1000"
)
# Returns: dict with BankLeft, BankRight keys
Modify Cross Section
# Read current geometry
df = GeomCrossSection.get_station_elevation(
"model.g01",
"Ohio River",
"Reach 1",
"1000"
)
# Modify elevations (e.g., lower channel 2 feet)
df.loc[df['Station'].between(100, 200), 'Elevation'] -= 2.0
# Get bank stations
banks = GeomCrossSection.get_bank_stations(
"model.g01",
"Ohio River",
"Reach 1",
"1000"
)
# Write back (creates .bak backup, handles bank interpolation)
GeomCrossSection.set_station_elevation(
"model.g01",
"Ohio River",
"Reach 1",
"1000",
df,
bank_left=banks['BankLeft'],
bank_right=banks['BankRight']
)
Update 2D Manning's n
from ras_commander.geom.GeomLandCover import GeomLandCover
# Read land cover table
lc_df = GeomLandCover.get_base_mannings_n("model.g01")
# Returns: DataFrame with LandCoverID, ManningsN
# Modify roughness
lc_df.loc[lc_df['LandCoverID'] == 42, 'ManningsN'] = 0.15
# Write back (creates .bak backup)
GeomLandCover.set_base_mannings_n("model.g01", lc_df)
Extract Storage Areas
from ras_commander.geom.GeomStorage import GeomStorage
# List storage areas (exclude 2D flow areas)
storage_areas = GeomStorage.get_storage_areas("model.g01", exclude_2d=True)
# Get elevation-volume curve
df = GeomStorage.get_elevation_volume("model.g01", "Detention Basin 1")
# Returns: DataFrame with Elevation, Area, Volume columns
Read Bridge Geometry
from ras_commander.geom.GeomBridge import GeomBridge
# List all bridges
bridges = GeomBridge.get_bridges("model.g01")
# Get bridge deck geometry
deck_df = GeomBridge.get_deck(
"model.g01",
"Ohio River",
"Reach 1",
"1000"
)
# Returns: DataFrame with Station, Elevation, Width, Distance
# Get pier data
piers_df = GeomBridge.get_piers(
"model.g01",
"Ohio River",
"Reach 1",
"1000"
)
# Returns: DataFrame with Station, Width, CD coefficients
Read Culverts
from ras_commander.geom.GeomCulvert import GeomCulvert
# Get all culverts in file
culverts_df = GeomCulvert.get_all("model.g01")
# Returns: DataFrame with River, Reach, RS, CulvertNum, Shape, etc.
# Filter by river/reach
culverts_df = GeomCulvert.get_all(
"model.g01",
river="Ohio River",
reach="Reach 1"
)
# Culvert shape codes:
# 1=Circular, 2=Box, 3=Pipe Arch, 4=Ellipse, 5=Arch
# 6=Semi-Circle, 7=Low Profile Arch, 8=High Profile Arch, 9=Con Span
Module Organization
| Module | Class | Purpose |
|--------|-------|---------|
| GeomParser | GeomParser | Fixed-width format parsing utilities |
| GeomCrossSection | GeomCrossSection | 1D cross section operations |
| GeomStorage | GeomStorage | Storage area elevation-volume curves |
| GeomLandCover | GeomLandCover | 2D Manning's n land cover tables |
| GeomLateral | GeomLateral | Lateral structures and SA/2D connections |
| GeomInlineWeir | GeomInlineWeir | Inline weir structures |
| GeomBridge | GeomBridge | Bridge/culvert structure geometry |
| GeomCulvert | GeomCulvert | Culvert data extraction |
| GeomPreprocessor | GeomPreprocessor | Geometry preprocessor file management |
See ras_commander/geom/AGENTS.md for complete API documentation.
Critical Implementation Notes
Bank Station Interpolation
Handled automatically - set_station_elevation() ensures bank stations appear as exact points:
- If bank station exists in data: uses it directly
- If bank station missing: interpolates elevation and inserts point
- You don't need to manually interpolate bank stations
450 Point Limit
HEC-RAS enforces maximum 450 points per cross section:
# Validate before writing
if len(df) > 450:
raise ValueError(f"Cross section has {len(df)} points (max 450)")
Case-Sensitive Identifiers
River, Reach, and RS are case-sensitive:
# These are DIFFERENT:
GeomCrossSection.get_station_elevation(geom_file, "Ohio River", ...)
GeomCrossSection.get_station_elevation(geom_file, "ohio river", ...)
Use exact casing from get_cross_sections() DataFrame.
Automatic Backups
All write operations create .bak files:
Original: model.g01
Modified: model.g01
Backup: model.g01.bak
Fixed-Width Format
HEC-RAS uses FORTRAN-era formatting:
- Column width: 8 characters per value
- Values per line: 10 values (80 characters total)
- Count interpretation:
#Sta/Elev= 40means 40 PAIRS (80 total values)
See ras_commander/geom/AGENTS.md for parsing algorithm details.
Common Workflows
Batch Modify All Cross Sections
# Get list of all cross sections
xs_df = GeomCrossSection.get_cross_sections("model.g01")
# Iterate through each
for _, row in xs_df.iterrows():
river = row['River']
reach = row['Reach']
rs = row['RS']
# Read geometry
df = GeomCrossSection.get_station_elevation("model.g01", river, reach, rs)
# Apply modification (e.g., raise all elevations 1 foot)
df['Elevation'] += 1.0
# Get bank stations
banks = GeomCrossSection.get_bank_stations("model.g01", river, reach, rs)
# Write back
GeomCrossSection.set_station_elevation(
"model.g01",
river,
reach,
rs,
df,
bank_left=banks['BankLeft'],
bank_right=banks['BankRight']
)
Extract All Storage Curves
from ras_commander.geom.GeomStorage import GeomStorage
# List storage areas (exclude 2D flow areas)
storage_areas = GeomStorage.get_storage_areas("model.g01", exclude_2d=True)
# Extract elevation-volume curves
for area_name in storage_areas:
df = GeomStorage.get_elevation_volume("model.g01", area_name)
print(f"{area_name}: {len(df)} elevation points")
# df has columns: Elevation, Area, Volume
Survey All Culverts
from ras_commander.geom.GeomCulvert import GeomCulvert
# Get all culverts in file
culverts_df = GeomCulvert.get_all("model.g01")
# Interpret shape codes
shape_map = {
1: "Circular", 2: "Box", 3: "Pipe Arch", 4: "Ellipse",
5: "Arch", 6: "Semi-Circle", 7: "Low Profile Arch",
8: "High Profile Arch", 9: "Con Span"
}
for _, row in culverts_df.iterrows():
shape_name = shape_map[row['Shape']]
print(f"{row['River']} - {row['RS']}: {shape_name} culvert")
Error Handling
File Not Found
from pathlib import Path
# Verify file exists
if not Path(geom_file).exists():
raise FileNotFoundError(f"Geometry file not found: {geom_file}")
Invalid River/Reach/RS
# List available features first
xs_df = GeomCrossSection.get_cross_sections(geom_file)
print(xs_df[['River', 'Reach', 'RS']])
# Use exact casing
df = GeomCrossSection.get_station_elevation(
geom_file,
"Ohio River", # Exact case
"Reach 1", # Exact case
"1000" # Exact string
)
Point Limit Exceeded
# Validate before writing
if len(df) > 450:
# Option 1: Simplify geometry
from scipy.interpolate import interp1d
f = interp1d(df['Station'], df['Elevation'])
new_stations = np.linspace(df['Station'].min(), df['Station'].max(), 400)
df = pd.DataFrame({
'Station': new_stations,
'Elevation': f(new_stations)
})
# Option 2: Raise error for user to handle
raise ValueError(f"Cross section has {len(df)} points (max 450)")
Primary Sources
For complete details, navigate to:
-
ras_commander/geom/AGENTS.md- Parsing algorithms (fixed-width format, count interpretation)
- Complete API reference for all 9 modules
- Technical patterns and implementation notes
- Culvert shape codes table
- Deprecated class mappings
-
examples/201_1d_plaintext_geometry.ipynbandexamples/202_2d_plaintext_geometry.ipynb- Working code demonstrations for all modules
- Real HEC-RAS project examples
- Output visualizations
- Error handling examples
- Integration with other ras-commander features
Import Pattern
All classes use static methods - no instantiation required:
from ras_commander.geom.GeomCrossSection import GeomCrossSection
from ras_commander.geom.GeomStorage import GeomStorage
from ras_commander.geom.GeomBridge import GeomBridge
from ras_commander.geom.GeomCulvert import GeomCulvert
from ras_commander.geom.GeomLandCover import GeomLandCover
# Use directly (no instantiation)
xs_df = GeomCrossSection.get_cross_sections("model.g01")
See Also
- CLAUDE.md: Architecture section on geometry parsing (lines 165-220)
- Subagent:
.claude/agents/geometry-parser/SUBAGENT.md- For delegation
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/hec-ras-geometry-file-parsing-mmbizk9i/download' --output '.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i/SKILL.md.part' && mv '.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i/SKILL.md.part' '.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i/SKILL.md' && test -s '.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/parsing-hecras-geometry' && cp -R '.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i' '.claude/skills/parsing-hecras-geometry'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i'openskills read 'hec-ras-geometry-file-parsing-mmbizk9i'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/hec-ras-geometry-file-parsing-mmbizk9i/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
Create Interactive Maps with kepler.gl
Data & AI
Create interactive map visualizations and export standalone HTML using the keplergl Python package. Use to plot geospatial data from DataFrames, GeoJSON, or CSV.
Agent-Driven Parameter Optimization
Data & AI
Guide for optimizing configurable systems with a measurable objective, using bounded trials and evidence-based recommendations.
ICP Visitor Outreach
Data & AI
Identify signed-up users matching the ideal customer profile but stalled, and draft personalized outreach to re-engage them.