Geometry Modules¶
Classes for parsing and modifying HEC-RAS geometry files.
Unified Cross-Section Points¶
RasCrossSections.get_points(project, geometry) exports the same stable point
schema from a plain-text .g## geometry or compiled .g##.hdf. Pass a
RasPrj, project folder, or .prj file for project; pass a geometry number,
title, text path, or HDF path for geometry. source="auto" prefers an
available HDF for project geometry selectors, while an explicit source path
keeps its source type.
from ras_commander import RasCrossSections
points = RasCrossSections.get_points("Muncie.prj", "01")
points.to_csv("muncie-xs-points.csv", index=False)
The frame includes model/geometry/reach/XS identifiers; exact river, reach, and
river-station strings; native and station order; cut-line relative distance;
XYZ; Manning's n and bank fields; horizontal CRS/units; vertical units/datum;
vertical_units_source; and source/extraction provenance. Native elevations are preserved by default.
A vertical datum is never inferred from a horizontal CRS or a model centroid.
When the source does not store a datum, pass vertical_datum= explicitly;
vertical_units= is the highest-priority override, followed by the full
project's text .prj marker. A direct HdfXsec.get_xs_coords() call uses only
genuinely explicit HDF vertical-unit metadata and does not infer units from
generic HDF unit-system flags. The source column reports explicit,
project_text, geometry_hdf_explicit, or unknown.
The identifiers are deterministic within one export; collection-wide model identity remains the responsibility of the consuming catalog. Prefer Parquet for large exports because the complete transform-provenance JSON is repeated per point and can make CSV files unnecessarily large.
Vertical conversion is opt-in through VerticalTransform. Use either an exact
PROJ pipeline or explicit source and target 3D/compound CRSs. The operation is
run against every point's own X/Y/Z coordinate, and the requested operation,
resolved PROJ definition, datum/unit labels, and PROJ/pyproj versions are
stored in vertical_transform_provenance and DataFrame.attrs.
from ras_commander import RasCrossSections, VerticalTransform
transform = VerticalTransform(
source_vertical_datum="NAVD88",
target_vertical_datum="Local project datum",
source_vertical_units="ft",
target_vertical_units="ft",
pipeline="+proj=pipeline +step +proj=affine +zoff=1.25",
)
adjusted = RasCrossSections.get_points(
"Muncie.prj",
"01",
vertical_datum="NAVD88",
vertical_transform=transform,
)
An affine offset is shown only to make the explicit operation easy to inspect. For geodetic vertical transformations, use the project-approved PROJ pipeline or full compound CRS definitions and confirm required grid files are installed.
RAS Mapper Reach-Length QA¶
RasGeometryCompute.assess_flow_path_policy() determines whether a joined 1D
reach may safely regenerate its overbank flow paths. It copies the whole project,
forces RAS Mapper to regenerate flow paths on the copy, recomputes LOB/channel/ROB
reach lengths, and compares them with the stored values. The source project is
never modified.
from ras_commander import RasGeometryCompute
policy = RasGeometryCompute.assess_flow_path_policy(
"JoinedModel.g01.hdf",
tolerance_fraction=0.01,
)
print(policy.recommended_policy)
display(policy.reach_metrics_df)
display(policy.xs_metrics_df)
The recommendation is regenerate_and_recompute only when every usable LOB and
ROB interval reproduces its stored length within 1%. Otherwise it is
preserve_and_recompute_only_at_join_boundary. The preserve policy is also selected
when no source flow paths span a reach but its stored overbank lengths differ
from the channel lengths. This prevents an automatically generated path from
silently replacing evidence of intentionally different overbank routing.
For a provisional joined reach, pass the two cross sections adjacent to the join. The method returns exactly one regenerated left and right segment clipped between those cut lines. Save the review evidence directly as GeoParquet when desired:
policy = RasGeometryCompute.assess_flow_path_policy(
"JoinedModel.g01.hdf",
join_upstream_xs=("Walnut", "Main", "5304.8"),
join_downstream_xs=("Walnut", "Main", "4884.4"),
review_segments_path="working/walnut_join_flow_paths.parquet",
)
display(policy.join_segments_gdf[["side", "length", "geometry"]])
Join selectors may use the full-precision restationed values returned by
RasBreakout1D.assemble_network_edge().seams_gdf. Compiled geometry HDF files
can store those values at a shorter displayed precision; the selector accepts a
unique match within one unit of that displayed precision and still fails closed
when more than one cross section could match.
The clipped segment lengths supply only the new join interval's LOB/ROB values; the remaining stored source lengths stay unchanged under the preserve policy. The returned geometries should be retained for visual review.
audit_main_channel_lengths() is the independent, read-only informative QA
check. It accepts either a plain-text .g## geometry or a compiled .g##.hdf,
measures the distance between adjacent cross-section intersections along the
river centerline, and compares that distance with the stored channel reach
length. It flags non-terminal intervals outside the supplied relative tolerance
or with an invalid centerline intersection.
channel_audit = RasGeometryCompute.audit_main_channel_lengths(
"WALNUT 0229.g01",
tolerance_fraction=0.01,
)
display(channel_audit[channel_audit["main_channel_flagged"]])
These APIs follow HEC's documented distinction: channel length comes from the river line, while LOB/ROB lengths come from flow paths. Automatically generated flow paths are review starting points rather than reconstructions of engineering judgment. See the official HEC-RAS Mapper pages for Cross Sections Rivers, River Station Markers, and Flow Path Lines.
GeomProjection¶
Model geometry reprojection helpers for copied HEC-RAS projects and plain-text geometry files.
Methods¶
reproject_model_geometry(project_path, source_crs, destination_crs, dest_folder=None, ...)- Copy a project folder, transform authored.g##model geometry coordinates, write a destination ESRI projection file, update copied.rasmapRASProjectionFilenamereferences, and return terrain / compiled-geometry rebuild requirements.reproject_geometry(geom_file, source_crs, destination_crs, output_geom=None, ...)- Transform one plain-text.g##file. By default writes a sibling copied geometry named*_reprojected.g##.
Both methods accept CRS inputs supported by pyproj.CRS.from_user_input(),
plus ESRI .prj file paths or WKT text. Datum shifts are rejected by default
because HEC-RAS project reprojection cannot reproduce geodetic datum
transformations. Set allow_datum_shift=True only after a project-specific
engineering review.
reproject_model_geometry() always works on a copied project folder. The
destination cannot be the source project folder or a child of it, even with
overwrite=True.
from ras_commander import GeomProjection
report = GeomProjection.reproject_model_geometry(
project_path="Muncie.prj",
source_crs="EPSG:5070",
destination_crs="EPSG:26915",
dest_folder="Muncie_reprojected",
)
print(report["projection_file"])
print(report["terrain_requirements"])
The reprojection writer transforms authored text geometry such as river reach
XY lines, cross-section GIS cut lines, storage-area and 2D perimeters, 2D seed
points, breaklines, SA/2D connection lines, BC lines, reference lines, and IC
point positions. It intentionally does not transform station/elevation
tables, bank stations, compiled .g##.hdf geometry, refinement-region HDF
datasets, terrain HDF/raster pixels, land-cover rasters, infiltration rasters,
or sediment bed-material rasters. The returned report identifies compiled
geometry preprocessing requirements, refinement-region HDF integrity findings,
and terrain layers whose CRS no longer matches the destination project CRS.
Use existing CRS inspection and validation APIs with the returned report:
RasPrj.refresh_project_crs()to refresh the active project's inferred CRS.RasMap.parse_rasmap()to inspect.rasmapprojection and terrain paths.RasMapValidation.check_layer_crs()to validate GIS/raster layers against an expected EPSG code.HdfBase.get_projection()to inspect HDF or rasmap-associated projection metadata.
RasGeometry¶
Comprehensive 1D geometry parsing and modification.
Cross Section Methods¶
get_cross_sections(geom)- List all cross sectionsbuild_cross_section(input_spec=None, **kwargs)- Build a complete Type 1 cross-section geometry entry from station/elevation, terrain, adjacent XS, bank, Manning's n, and reach-length inputsget_station_elevation(geom, river, reach, station)- Get station-elevation pairsset_station_elevation(geom, river, reach, station, sta_elev)- Modify station-elevationget_mannings_n(geom, river, reach, station)- Get Manning's n valuesget_bank_stations(geom, river, reach, station)- Get bank station locations
Cross Section Builder¶
GeomCrossSection.build_cross_section() returns a CrossSectionBuildResult
with resolved station/elevation, bank stations, Manning's n breakpoints, reach
lengths, fallback messages, and formatted .g## geometry lines. The method
accepts either keyword arguments or a CrossSectionBuildInput dataclass.
from ras_commander import (
CrossSectionBankStations,
CrossSectionManningsN,
CrossSectionReachLengths,
GeomCrossSection,
)
result = GeomCrossSection.build_cross_section(
river="Example River",
reach="Main",
rs="1000",
terrain_profile=terrain_df, # columns: station/elevation or Station/Elevation
cut_line=[(0.0, 0.0), (500.0, 0.0)],
river_centerline=[(250.0, -50.0), (250.0, 50.0)],
)
entry_text = result.text
Fallback behavior is intentionally visible. Every fallback logs at ERROR
level with river|reach|RS and also appears in result.fallback_messages.
The builder always writes required Bank Sta=, #Sta/Elev=, and #Mann=
records when enough station/elevation data can be resolved.
Resolution order:
- Station/elevation: explicit
station_elevation, terrain profile orRasTerrainMod.get_terrain_profile(), then adjacent XS interpolation. - Bank stations: explicit station/elevation, explicit stations with terrain elevations, river-centerline intersection with default 20-unit main-channel width, then profile-interpolated bank elevations when terrain is unavailable.
- Manning's n: controlled by
mannings_strategy.autoprefers land cover, neighboring XS interpolation, user values, then defaults (MC=0.06,LOB=ROB=0.08). Strategieslandcover,neighbor,user, anddefaultmake a source preferred. - Point count: station/elevation output is capped at 500 points using a Douglas-Peucker-style reducer that preserves endpoints, banks, the thalweg, and major slope breaks.
Fully specified inputs avoid fallbacks:
result = GeomCrossSection.build_cross_section(
river="Example River",
reach="Main",
rs="1000",
station_elevation=survey_df,
bank_stations=CrossSectionBankStations(120.0, 180.0, 534.2, 533.8),
mannings_n=CrossSectionManningsN(lob=0.08, channel=0.05, rob=0.08),
reach_lengths=CrossSectionReachLengths(left=400.0, channel=390.0, right=410.0),
)
assert result.fallback_messages == []
Storage Area Methods¶
get_storage_areas(geom)- List storage areasget_storage_elevation_volume(geom, name)- Get elevation-volume curve
Lateral Structure Methods¶
get_lateral_structures(geom)- List lateral structuresget_lateral_weir_profile(geom, name)- Get weir profile
Connection Methods¶
get_connections(geom)- List SA/2D connectionsget_connection_weir_profile(geom, name)- Get connection weir profileget_connection_gates(geom, name)- Get gate data
RasGeometryUtils¶
Parsing utilities for HEC-RAS geometry files.
Methods¶
parse_fixed_width(line, width=8)- Parse fixed-width formatted lineparse_count_line(line)- Parse count header lineinterpolate_bank_station(sta_elev, bank)- Interpolate bank station elevation
GeomReferenceFeatures¶
Reference line and reference point helpers for 2D calibration and native reference-line output.
Reference Line Methods¶
add_reference_lines(geom_file, lines, storage_area)- Insert manually supplied reference lines into a.g##filereplace_reference_lines(geom_file, storage_area, reference_lines, *, expected_existing_names=..., create_backup=True)- Atomically replace or remove one existing 2D area's complete reference-line collection while preserving other areas; returns the backup path, orNonewhen backups are disabledgenerate_reference_lines_from_longitudinal_line(...)- Generate transverse reference-line dictionaries at regular station intervals along a named longitudinal lineadd_reference_lines_from_longitudinal_line(...)- Generate and write transverse reference lines through the existing.g##writerget_reference_lines(geom_file)- Read reference lines from a.g##file
Automated Reference Lines¶
from ras_commander import GeomReferenceFeatures
reference_lines = GeomReferenceFeatures.generate_reference_lines_from_longitudinal_line(
centerlines_gdf,
longitudinal_line_name="Main River",
spacing=500.0,
line_length=1500.0,
name_template="MainRiver_{station_int}",
)
GeomReferenceFeatures.add_reference_lines(
"MyModel.g01",
reference_lines,
storage_area="Perimeter 1",
)
For result-guided orientation, pass orientation="velocity" or
orientation="depth_velocity" with orientation_plan_hdf. Generated lines fall
back to normal-to-line orientation unless orientation_fallback="raise" is set.
GeomMesh¶
Headless 2D mesh generation helpers and compiled geometry HDF refinement-region utilities.
Domain and Mesh Methods¶
audit_domain_containment(geom_number, mesh_name=..., cell_size=..., ras_object=...)- Fail closed unless every breakline, refinement region, and structure associated with the selected 2D area is wholly covered by the exact compiled perimeter buffered inward by one base mesh-cell spacing. BC lines are intentionally excluded because they are authored on the perimeter and require a separate association/overlap audit.generate(geom_number, mesh_name=..., ras_object=...)- Regenerate the mesh and automatically run the same inward one-cell containment gate before loading native RAS Mapper dependencies.compute_property_tables(geom_number, mesh_name=..., ras_object=...)- Compute face profiles, Manning's n assignments, face hydraulic tables, and cell properties against the restored geometry associations.
HEC-RAS Version Support for Headless Mesh Generation¶
GeomMesh.generate() and GeomMesh.compute_property_tables() support
HEC-RAS 6.0 through 7.0.1, including the 6.7 betas. They run RASMapper's own
mesh engine (RasMapperLib.dll) from the HEC-RAS installation they load, so
each release produces its own RASMapper result.
| HEC-RAS | Headless mesh generation | Notes |
|---|---|---|
| 6.6, 6.7 Beta 4, 6.7 Beta 5, 7.0, 7.0.1 | Supported | Full retry ladder, including minimum face-length ratio escalation. |
| 6.3 – 6.5 | Supported | No minimum face-length ratio escalation (see below). |
| 6.0 – 6.2 | Supported | As above. Preprocessing needs every land-cover, infiltration, and sediment file the geometry references (see below). |
Why older releases need different calls. Two RasMapperLib members changed
their parameters between releases, and generate() adapts to whichever form
the loaded release has:
| RasMapperLib member | 6.0 – 6.2 | 6.3 – 6.3.1 | 6.4.1 – 6.5 | 6.6 and later |
|---|---|---|---|---|
MeshFV2D(perimeter, points, breaklines, progress, ...) constructor |
4 parameters | 4 | 4 | 5 (adds minFaceLengthRatio) |
PointGenerator.RegenerateMeshPoints (breakline-aware seeding) |
4 parameters | 6 (adds progress reporters) | 7 (adds treatInactiveAsNotPresent) |
7 |
RASD2FlowArea.CreatePropertyTables (used by compute_property_tables) |
3 parameters | 4 (adds per-task reporters) | 4 | 4 |
Before 6.6, MeshFV2D has no minimum face-length ratio, so generate() skips
the ratio-escalation step of its retry ladder. A mesh that 6.6 completes only
after raising the ratio can therefore fail on 6.0 – 6.5; the other retry steps
still apply.
Known limitations.
- HEC-RAS 6.0 – 6.2 and missing referenced files. If a land-cover,
infiltration, or sediment file referenced by the geometry is missing,
HEC-RAS 6.0 – 6.2 skip the geometry during preprocessing without an error,
and the plan HDF has no 2D mesh. With these releases,
RasPreprocess.preprocess_plan()checks for the files first and fails, naming each missing file, instead of reporting success. HEC-RAS 6.3 and later preprocess the mesh anyway, so the check does not apply to them. - Property-table values differ by release.
compute_property_tables()writes tables on every supported release, but HEC-RAS changed its property-table computation over time. Values from 6.0 – 6.3.1 differ from 6.4.1 and later, which match each other. - Terms and Conditions for Use. A release must have its TCU accepted for
the current user before
Ras.execan preprocess headlessly.
Selecting the HEC-RAS version. Without hecras_dir, generate() loads the
newest installed release it finds (7.0.1, 7.0, 6.6, 6.7 Beta 5, then 6.5 down
to 6.0), regardless of the project's version. Pass hecras_dir to pin the
release. Only one RasMapperLib version can be loaded per Python process.
Linux / Wine. The same behavior applies under Wine
(rascommander/hec-ras-wine-precompute_{version} images). Loading
RasMapperLib there also requires the C:\Python311\GDAL link to the HEC-RAS
GDAL folder, prepared from the Linux side.
How refinement regions were tested. A region-only A/B test uses the real
RasExamples Chippewa_2D project: a 200-ft base mesh (357 cells), followed by a
1,600-ft-square refinement region requesting 40-ft spacing. RAS Mapper must
reload the authored region before regeneration, the refined mesh must contain
2,118 cells, and median nearest-neighbor spacing inside the region must be
40 ft. Native Windows produced the same result on every locally installed 6.x
runtime: 6.0, 6.1, 6.2, 6.3, 6.3.1, 6.5, 6.6, and 6.7 Beta 5. A 6.4/6.4.1
installation was not available for this qualification. The private
RegenerateMeshPoints API was also reflected independently in each process:
activeRegions is parameter 2 in every tested release; only the documented
trailing argument count changes.
HEC-RAS 6.6 was also qualified under Wine 11.0 on CLB07 using the pinned
rascommander/hec-ras-wine-precompute_6.6 runtime. Both the RAS Mapper
product-layer writer and the native-schema fallback produced 2,118 generated
computation points (also the HDF Cell Count), 2,209 compiled cell-center
rows, 4,376 faces, and 1,600 centers inside the region at exactly 40-ft median
nearest-neighbor spacing; outside-region spacing was 122.327 ft. The run used
an isolated writable prefix and the Linux-side C:\Python311\GDAL link noted
above.
HEC-RAS Refinement-Region Caveats¶
- Independent Y spacing is not implemented by HEC-RAS. RAS Mapper stores
both X and Y spacing, but the 6.6 Mapper manual labels Cell Spacing Y as
"not implemented yet."
spacing_dyis preserved for schema fidelity; do not interpret a different Y value as verified anisotropic refinement. - HEC-RAS 6.2 GUI row reordering. HEC documented that reordering the
Refinement Region Editor table could create duplicate regions and deleting
those duplicates could crash. The documented workaround was the feature
Send...command; HEC lists the defect as fixed in 6.3. ras-commander does not drive that GUI reorder path. - HEC-RAS 6.4 breakline interactions. HEC fixed lost properties after splitting breaklines, incorrect one-cell protection-radius behavior when breakline/region inclusion was disabled, and some breaklines that failed to enforce. Prefer 6.4 or later for models combining these behaviors.
- HEC-RAS 6.6 perimeter-loss symptom. HEC documented exceptional cases in which a 2D perimeter disappeared and the mesh stopped updating or selecting. Product-backed authoring therefore backs up the geometry HDF and requires a fresh RAS Mapper reload before reporting success.
- HEC-RAS 6.7 betas. Beta 2/3 had an initial mesh-recompute "Unknown Error"/arithmetic-overflow issue. Beta 5 passes the region-only qualification above, but a stable release is preferable for production.
See HEC's official 6.2 known issues, 6.3 fixes, 6.4 fixes, 6.6 known issues, 7.0's archived beta fixes, and the 6.6 Mapper manual.
Refinement Region Methods¶
add_refinement_region(geom_number, polygon, spacing_dx, ...)- Add one refinement polygon through RAS Mapper on Windows/Wine, with backup and product-reload verification. The portable fallback writes the complete native nine-field HDF record and semantic polygon metadata.add_flowline_refinement_regions(geom_number, flowlines, buffer_width, ...)- Buffer GeoDataFrame or LineString channel flowlines into refinement-region polygons, optionally simplify/trim them, write them throughadd_refinement_region(), and return FID/name/spacing mappings.replace_refinement_regions(geom_number, regions, expected_existing_names=..., ...)- Atomically replace or remove the complete HDF refinement-region collection, with an optional optimistic-concurrency guard.get_refinement_regions(geom_number)- Read refinement-region FID, name, and spacing values from a compiled geometry HDF.set_refinement_region_spacing(geom_number, spacing_dx, ...)- Update spacing for one or more existing refinement regions.set_refinement_region_name(geom_number, new_name, ...)- Rename an existing refinement region.
Structure APIs¶
Inline structures are exposed through the public GeomInlineWeir,
GeomBridge, and GeomCulvert classes. There is no public RasStruct class.
Inline Weir Methods¶
GeomInlineWeir.get_weirs(geom, river=None, reach=None)- List inline weirsGeomInlineWeir.get_profile(geom, river, reach, station)- Get weir profileGeomInlineWeir.get_gates(geom, river, reach, station)- Get gate data
Bridge Methods¶
GeomBridge.get_bridges(geom)- List bridgesGeomBridge.get_deck(geom, river, reach, station)- Get deck profileGeomBridge.get_piers(geom, river, reach, station)- Get pier dataGeomBridge.get_abutment(geom, river, reach, station)- Get abutment dataGeomBridge.get_approach_sections(geom, river, reach, station)- Get approach sectionsGeomBridge.get_coefficients(geom, river, reach, station)- Get coefficientsGeomBridge.get_hydraulic_methods(geom, river, reach, station)- Get bridge low-flow/high-flow method selections fromBridge Culvert-,Deck Dist Width WeirC,BR Coef=, andWSPro=recordsGeomBridge.set_hydraulic_methods(geom, river, reach, station, low_flow_method=..., high_flow_method=..., weir_coefficient=...)- Set bridge modeling approach method selections and related coefficientsGeomBridge.get_htab(geom, river, reach, station)- Get HTAB settings
Accepted low_flow_method values are energy, momentum, yarnell, and wspro.
Accepted high_flow_method values are energy and pressure_weir.
Optional compute flags are use_energy, use_momentum, use_yarnell, and use_wspro.
Optional coefficient fields include momentum_cd, yarnell_k, pressure_flow_submerged_inlet_cd, pressure_flow_submerged_inlet_outlet_cd, and positive weir_coefficient.
Unsupported combinations, such as disabling the selected low-flow method or selecting Momentum/Yarnell without an existing or supplied coefficient, raise ValueError.
Culvert Methods¶
GeomCulvert.get_culverts(geom, river, reach, station)- Get all culverts at a bridge/culvert structureGeomCulvert.get_all(geom, river=None, reach=None)- Get all culverts in a geometry fileGeomCulvert.set_culverts(geom, river, reach, station, culverts)- Replace culvert records at an existing bridge/culvert structureGeomCulvert.set_culvert(geom, river, reach, station, culvert=None, culvert_index=None, culvert_name=None, **kwargs)- Update one culvert by index/name or append a new oneGeomCulvert.get_adjacent_cross_sections(geom, river, reach, station)- Find the nearest upstream and downstream cross sections around a structureGeomCulvert.set_adjacent_ineffective_flow(geom, river, reach, station, upstream_ineffective=None, downstream_ineffective=None, ...)- Coordinate ineffective-flow writes on adjacent cross sections
set_culverts() accepts a DataFrame, list of dictionaries, or one dictionary. Shape can be supplied as Shape code or ShapeName for any taxonomy-backed HEC-RAS culvert shape: Circular, Box, Pipe Arch, Ellipse, Arch, Semi-Circle, Low Profile Arch, High Profile Arch, or Con Span. Required fields are validated against culvert_taxonomy.json, including shape-specific dimensions, positive/nonnegative numeric ranges, Chart #/Scale# combinations, a maximum of 10 culvert groups per crossing, and a maximum of 25 identical barrels per group. The API preserves legacy field names InletType and OutletType for HEC-RAS Chart # and Scale#; ChartID and ScaleID aliases are also accepted. Single-barrel records require UpstreamStation and DownstreamStation. Multi-barrel records require NumBarrels and matching BarrelStations pairs.
from ras_commander.geom.GeomCulvert import GeomCulvert
GeomCulvert.set_culverts(
"model.g01",
"River",
"Reach",
"1000",
[
{
"ShapeName": "Circular",
"Span": 6,
"Length": 50,
"ManningsN": 0.013,
"EntranceLoss": 0.5,
"ExitLoss": 1.0,
"InletType": 1,
"OutletType": 1,
"UpstreamInvert": 25.1,
"UpstreamStation": 996,
"DownstreamInvert": 25.0,
"DownstreamStation": 996,
"CulvertName": "Culvert #1",
},
{
"ShapeName": "Pipe Arch",
"Span": 7,
"Rise": 5,
"Length": 48,
"ManningsN": 0.024,
"EntranceLoss": 0.4,
"ExitLoss": 1.0,
"ChartID": 34,
"ScaleID": 1,
"UpstreamInvert": 26.2,
"UpstreamStation": 1000,
"DownstreamInvert": 25.8,
"DownstreamStation": 1000,
"CulvertName": "Pipe Arch",
},
{
"ShapeName": "Box",
"Span": 4,
"Rise": 4,
"Length": 55,
"ManningsN": 0.015,
"EntranceLoss": 0.3,
"ExitLoss": 1.0,
"InletType": 8,
"OutletType": 1,
"UpstreamInvert": 27.5,
"DownstreamInvert": 27.0,
"NumBarrels": 2,
"BarrelStations": [(980, 980), (1020, 1020)],
"CulvertName": "Twin Box",
},
],
)
GeomCrossSection¶
Cross-section authoring and blocked-obstruction management.
Cross Section Builder¶
build_cross_section(input_spec=None, **kwargs)- Build complete cross-section geometry entry from terrain, survey, or adjacent XS dataget_blocked_obstructions(geom_file, river, reach, rs)- Read blocked obstructions for a cross sectionset_blocked_obstructions(geom_file, river, reach, rs, obstructions)- Write blocked obstructions
See the Cross Section Builder section above for resolution order and fallback behavior.
GeomBridge¶
Bridge geometry authoring (deck profiles, piers, abutments, approach sections).
Methods¶
get_bridges(geom_file, river=None, reach=None)- List bridgesget_deck(geom_file, river, reach, rs)- Read bridge deck profileset_deck(geom_file, river, reach, rs, deck_data, ...)- Write bridge deck profile
GeomBcLines¶
2D boundary condition line geometry authoring.
Methods¶
add_bc_line(geom_file, flow_area, name, coordinates, bc_type)- Add BC line to 2D flow areaget_bc_lines(geom_file, flow_area=None)- Read existing BC linesremove_bc_line(geom_file, flow_area, name)- Remove a BC line
GeomLateral¶
Lateral structure parsing and modification.
Methods¶
get_lateral_structures(geom_file)- List lateral structuresget_lateral_weir_profile(geom_file, name)- Get weir profile data
GeomStorage¶
Storage area and 2D flow area geometry parsing and writing.
Methods¶
get_storage_areas(geom_file)- List storage areas with elevation-volume dataget_2d_flow_areas(geom_file)- List 2D flow areas with settingsget_2d_flow_area_settings(geom_file)- Read 2D flow area computation settingsset_2d_flow_area_settings(geom_file, area_name, **settings)- Write 2D flow area settings (subgrid sampling, composite classification)write_2d_flow_area_perimeter(geom_file, area_name, coordinates, ...)- Write 2D flow area perimeterreplace_breaklines(geom_file, flow_area_name, breaklines, expected_existing_names=..., ...)- Atomically replace the geometry-global breakline collection while preserving supplied near/far spacing, near-repeat, and protection-radius values.
MeshRegenerationWorkflow¶
Exact RAS Mapper geometry import and legacy mesh-regeneration GUI workflows.
Methods¶
refresh_geometry_hdf_from_text(geom_number=..., geometry_name=..., flow_area_name=..., ras_object=..., ...)- Transactionally displace one exact geometry HDF, let the explicitly initialized HEC-RAS version rebuild it from task-local.g##text, validate the exact 2D perimeter and sibling-HDF isolation, and roll back on failure. This imports geometry features but does not create computation cells.regenerate_mesh(geom_number=..., geometry_name=..., flow_area_name=..., ras_object=..., ...)- Open/save and validate an already-current exact geometry and compiled mesh.regenerate_mesh_iterative(...)- Legacy retry workflow; exact geometry selectors are supported and no first-registration fallback is used.
GeomLevee¶
Levee station-elevation parsing and modification.
Methods¶
get_levees(geom_file, river=None, reach=None, rs=None)- Read levee data for cross sectionsset_levees(geom_file, river, reach, rs, levee_data)- Write levee station-elevation data
RasBreach¶
Breach discovery and parameter modification in plan files. Detailed computed
results are read separately through HdfResultsBreach.
Methods¶
list_breach_structures_plan(plan_input, *, ras_object=None)- Return one dictionary per stored definition withstructure,river,reach,station, and local storedis_activeread_breach_block(plan_input, structure_name, *, ras_object=None)- Return the named definition's location, rawvalues, and parsedtable_rowsupdate_breach_block(plan_input, structure_name, *, is_active=None, method=None, geom_values=None, start_values=None, progression_mode=None, progression_pairs=None, downcutting_pairs=None, widening_pairs=None, calculator_data=None, dlb_methods=None, dlb_soil_type=None, dlb_soil_properties=None, dlb_core_soil_type=None, dlb_cover_option=None, dlb_cover_soil_properties=None, dlb_breach_direction=None, user_growth_flag=None, user_growth_ratio=None, mass_wasting_option=None, create_backup=True, ras_object=None)- Update complete stored fields and tablesset_breach_geom(plan_input, structure_name, *, centerline=None, final_bottom_width=None, final_bottom_elev=None, left_slope=None, right_slope=None, failure_mode=None, piping_coefficient=None, initial_piping_elevation=None, formation_time=None, weir_coefficient=None, initial_width=None, weir_coef=None, active=None, top_elev=None, formation_method=None, ras_object=None)- Update selected fields in theBreach Geomrecord;initial_width/weir_coefare deprecated safe aliases, while the three other legacy keywords fail closed with migration guidancecreate_breach_block(plan_input, structure_name, *, river="", reach="", station="", is_active=True, create_backup=True, ras_object=None)- Create a new minimal stored breach block
The list output is the structure-level discovery API. Project-level
plan_df contains only breach_definition_count and
breach_active_count; it does not duplicate the full definition records.
Usage Examples¶
Cross Section Modification¶
from ras_commander import RasGeometry, init_ras_project
init_ras_project("/path/to/project", "6.5")
# Get station-elevation
sta_elev = RasGeometry.get_station_elevation("01", "River", "Reach", "1000")
# Modify and save
sta_elev['elevation'] = sta_elev['elevation'] - 2.0
RasGeometry.set_station_elevation("01", "River", "Reach", "1000", sta_elev)