RASMapper¶
Use these dedicated references for related tasks:
| Task | Reference |
|---|---|
| Generate, diagnose, or repair a 2D mesh | Meshing |
| Sample results, profiles, or reference hydrographs | Results Queries |
| Export computed results to raster maps | Stored Maps |
| Create, modify, or export terrain | Terrain |
This page covers the remaining RASMapper operations: screenshots and spatial review, map and geometry layers, display controls, geometry associations, and native geometry completion. Use the static namespaces directly; there is no single RASMapper object to instantiate. File readers and XML editors can run without a visible desktop. Native methods need their documented HEC-RAS runtime; GUI capture additionally needs an interactive Windows desktop. A headless Wine qualification does not establish GUI screenshot support.
Registration in .rasmap and associations in compiled geometry HDF are distinct.
Changing visibility does not alter hydraulic results, and geometry completion
does not execute a hydraulic plan. Use RasCmdr for execution
and review the resulting evidence before exporting maps.
Inspect, configure, and capture¶
from pathlib import Path
from ras_commander import RasMap
project_path = Path("review-copy/Model.prj")
print(RasMap.list_map_layers(project_path))
print(RasMap.get_current_view(project_path))
# Register an existing vector layer on the copied project.
RasMap.add_reference_map_layer(
project_path,
source_path=Path("review-inputs/review-area.geojson"),
layer_name="Review area",
)
GeoJSON registration validates WGS84 compatibility. Use method-specific CRS
rules instead of assuming all layer inputs are in the model CRS.
clone_geometry_layer() registers an existing geometry clone; it does not copy
the geometry files. Use geometry cloning first, then register the new HDF and
verify its compiled associations.
On an interactive Windows review desktop:
from ras_commander import RasMap
snapshot = RasMap.screenshot_model(
"review-copy/Model.prj",
output_path="review-output/model.png",
ras_version="6.6",
)
if snapshot is None:
raise RuntimeError("No screenshot was captured; inspect the logged diagnostics")
print(snapshot)
create_spatial_review_package() can produce an evidence bundle without a
screenshot (capture_snapshot=False, the default). That path can still persist
display settings in .rasmap; it is not a read-only inventory. To require a
screenshot, select a GUI-capable runtime and use capture_snapshot=True with
require_snapshot=True. See the method for preflight and restoration behavior.
RASMapper display and spatial review¶
Use RasMap to select geometry and result layers, set visibility and view bounds,
and capture review evidence. Visibility and rendering changes are persisted in
.rasmap; HDF feature readers supply model bounds and feature inventories.
| Task | Input | Output |
|---|---|---|
| Layer and feature discovery | Project and exact geometry/layer selector | Lists or DataFrames |
| Visibility and terrain display | Layer selector and display options | Updated XML; Boolean or changed-entry count |
| View and zoom | Explicit bounds or HDF feature selector | View/bounds dictionary |
| Open/capture/close | Project and optionally an owned process ID | Process handle, optional PNG path, closed-window count |
| Screenshot gallery / review package | Projects and output directory | Gallery records or review-bundle dictionary |
Screenshots require Windows GUI facilities and a visible RASMapper window.
Prefer the process ID returned by open_rasmapper() when capturing or closing
that window. screenshot_model() temporarily configures display layers and
restores its .rasmap backup after capture. Read each method's return value;
an absent screenshot is not successful visual evidence.
Examples with retained outputs: 122 — spatial review, 123 — geometry layer updates, and 124 — bank lines.
Display, features and review methods¶
Class for parsing and accessing information from HEC-RAS mapper configuration files (.rasmap).
This class provides methods to extract paths to terrain, soil, land cover data, and various project settings from the .rasmap file associated with a HEC-RAS project. It also includes functionality to automate the post-processing of stored maps.
list_geometries
staticmethod
¶
List all geometry layers in the RASMapper configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_object
|
RasPrj
|
Optional RasPrj object instance. |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of dicts with geometry info: [{"name": str, "filename": str, "geom_number": str, "checked": bool}, ...] |
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project("/path/to/project", "7.0")
>>> geoms = RasMap.list_geometries()
>>> for g in geoms:
... print(f"{g['geom_number']}: {g['name']} - Visible: {g['checked']}")
Source code in ras_commander/RasMap.py
clone_geometry_layer
staticmethod
¶
clone_geometry_layer(source_geometry: Union[str, int], target_geometry: Union[str, int], *, name: Optional[str] = None, checked: bool = True, expanded: bool = True, ras_object=None) -> Dict[str, Any]
Register a cloned geometry HDF in the RASMapper tree.
RasGeo.clone_geom() copies the geometry control file and HDF, but
HEC-RAS does not add the cloned HDF to <Geometries> in the project
.rasmap file. Exact text-to-HDF refresh workflows therefore cannot
resolve the clone until it has a RASMapper geometry layer.
The source geometry layer is deep-copied so the target keeps the same child-layer display configuration. Only the top-level display name, visibility, expansion state, and HDF filename are changed. Repeating the call for the same target is idempotent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_geometry
|
Union[str, int]
|
Source geometry number, such as |
required |
target_geometry
|
Union[str, int]
|
Cloned geometry number, such as |
required |
name
|
Optional[str]
|
Optional target display name. Defaults to the source name. |
None
|
checked
|
bool
|
Whether the target geometry is visible. |
True
|
expanded
|
bool
|
Whether the target geometry tree is expanded. |
True
|
ras_object
|
RasPrj
|
Optional initialized :class: |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Registered layer metadata and the |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the |
ValueError
|
If the source layer is absent or the numbers are equal. |
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 | |
set_geometry_visibility
staticmethod
¶
Set visibility of a specific geometry layer in RASMapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_identifier
|
str
|
Geometry to modify - can be: - Geometry name (e.g., "1D-2D Dam Break Model Refined Grid") - Geometry number (e.g., "08" or "g08") - Filename pattern (e.g., "g08.hdf") |
required |
visible
|
bool
|
True to show geometry, False to hide. |
True
|
ras_object
|
RasPrj
|
Optional RasPrj object instance. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if geometry was found and modified. |
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project("/path/to/project", "7.0")
>>> # Show geometry by number
>>> RasMap.set_geometry_visibility("08", visible=True)
>>> # Hide geometry by name
>>> RasMap.set_geometry_visibility("Old Geometry", visible=False)
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 | |
set_all_geometries_visibility
staticmethod
¶
set_all_geometries_visibility(visible: bool = False, except_geom: Optional[str] = None, ras_object=None) -> int
Set visibility for all geometry layers, optionally excluding one.
This is useful for hiding all geometries except the one you want to display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visible
|
bool
|
True to show all geometries, False to hide all. |
False
|
except_geom
|
Optional[str]
|
Optional geometry to exclude from visibility change. Can be geometry name, number (e.g., "08"), or filename pattern. |
None
|
ras_object
|
RasPrj
|
Optional RasPrj object instance. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of geometries modified. |
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project("/path/to/project", "7.0")
>>> # Hide all geometries except G08
>>> RasMap.set_all_geometries_visibility(visible=False, except_geom="08")
>>> # Then show only G08
>>> RasMap.set_geometry_visibility("08", visible=True)
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 | |
list_geometry_layers
staticmethod
¶
list_geometry_layers(ras_project_path: Optional[Union[str, Path]] = None, *, ras_object=None) -> pd.DataFrame
List top-level geometries and child geometry elements from .rasmap.
This is the discoverable RASMapper tree view for geometry automation.
It includes both compiled geometry HDF entries and child elements such as
RASXS, RASD2FlowArea, MeshPerimeterLayer, and structure
layers. Use this when deciding what to toggle before opening RASMapper or
taking documentation screenshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Optional[Union[str, Path]]
|
Project folder, |
None
|
ras_object
|
RasPrj
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per top-level geometry and child geometry element, including layer id, layer type, visibility state, and resolved geometry HDF path. |
Source code in ras_commander/RasMap.py
set_geometry_layer_visibility
staticmethod
¶
set_geometry_layer_visibility(ras_project_path: Optional[Union[str, Path]] = None, *, checked: bool = True, layer_id: Optional[str] = None, layer_type: Optional[Union[str, Sequence[str]]] = None, layer_name: Optional[str] = None, geometry_name: Optional[str] = None, geometry_number: Optional[str] = None, exclusive: bool = False, ras_object=None) -> int
Toggle child geometry elements in the RASMapper tree.
This complements set_geometry_visibility(), which toggles a whole
compiled geometry. set_geometry_layer_visibility() targets child
elements inside that geometry, such as cross sections, 2D flow areas,
mesh perimeters, and structures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Optional[Union[str, Path]]
|
Project folder, |
None
|
checked
|
bool
|
|
True
|
layer_id
|
Optional[str]
|
Stable id from |
None
|
layer_type
|
Optional[Union[str, Sequence[str]]]
|
RASMapper child layer type, such as |
None
|
layer_name
|
Optional[str]
|
Optional child layer display name. |
None
|
geometry_name
|
Optional[str]
|
Optional parent geometry display name filter. |
None
|
geometry_number
|
Optional[str]
|
Optional parent geometry number filter, such as
|
None
|
exclusive
|
bool
|
If |
False
|
ras_object
|
RasPrj
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of XML visibility attributes modified. |
Source code in ras_commander/RasMap.py
list_result_layers
staticmethod
¶
list_result_layers(ras_project_path: Optional[Union[str, Path]] = None, *, ras_object=None) -> pd.DataFrame
List RASMapper result plans and child result layers.
The returned DataFrame includes the top-level RASResults plan rows
and nested result layers such as depth, WSE, velocity, or calculated
layers, with their current visibility state.
Source code in ras_commander/RasMap.py
set_result_layer_visibility
staticmethod
¶
set_result_layer_visibility(ras_project_path: Optional[Union[str, Path]] = None, *, checked: bool = True, layer_id: Optional[str] = None, plan_name: Optional[Union[str, Sequence[str]]] = None, layer_name: Optional[Union[str, Sequence[str]]] = None, layer_type: Optional[Union[str, Sequence[str]]] = None, exclusive: bool = False, ras_object=None) -> int
Toggle RASMapper result plans and child result layers.
When no selector is supplied, all result layers are targeted. Use
exclusive=True with checked=True to hide every non-matching
result layer and show only the selected result plan or map type needed
for a figure.
Source code in ras_commander/RasMap.py
list_geometry_features
staticmethod
¶
list_geometry_features(geometry_hdf_path: Union[str, Path], *, layer_type: Optional[Union[str, Sequence[str]]] = None) -> pd.DataFrame
List HDF geometry features for supported RASMapper layers.
This is more granular than list_geometry_layers(). It exposes
feature names, indexes, and bounds for objects such as 2D
flow areas, lateral structures, breaklines, and cross sections.
Source code in ras_commander/RasMap.py
get_current_view
staticmethod
¶
get_current_view(ras_project_path: Optional[Union[str, Path]] = None, *, ras_object=None) -> Dict[str, Any]
Read the CurrentView bounds from a project .rasmap file.
Bounds are in the project/RASMapper coordinate system. The returned
dictionary also includes the resolved projection file path when the
.rasmap references one.
Source code in ras_commander/RasMap.py
set_current_view
staticmethod
¶
set_current_view(ras_project_path: Optional[Union[str, Path]] = None, *, min_x: float, min_y: float, max_x: float, max_y: float, ras_object=None) -> Dict[str, Any]
Write the CurrentView bounds in a project .rasmap file.
Use this before launching standalone RASMapper when you want a deterministic documentation or QA/QC viewport.
Source code in ras_commander/RasMap.py
set_terrain_layer_visibility
staticmethod
¶
set_terrain_layer_visibility(ras_project_path: Optional[Union[str, Path]] = None, *, terrain_name: Optional[str] = None, checked: bool = True, exclusive: bool = False, surface_on: bool = True, ras_object=None) -> int
Toggle RASMapper terrain-layer visibility in a project .rasmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Optional[Union[str, Path]]
|
Project folder, |
None
|
terrain_name
|
Optional[str]
|
Optional terrain layer display name. When omitted, all terrain layers are targeted. |
None
|
checked
|
bool
|
|
True
|
exclusive
|
bool
|
If |
False
|
surface_on
|
bool
|
Keep the terrain |
True
|
ras_object
|
RasPrj
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of XML attributes/elements modified. |
Source code in ras_commander/RasMap.py
list_terrain_display_settings
staticmethod
¶
list_terrain_display_settings(ras_project_path: Optional[Union[str, Path]] = None, *, terrain_name: Optional[str] = None, ras_object=None) -> pd.DataFrame
List terrain display settings persisted in a project .rasmap file.
The returned DataFrame includes hillshade, contour, and stitch-edge
display controls for each Type="TerrainLayer" entry. These settings
are read directly from RASMapper XML; no GUI automation is used.
Source code in ras_commander/RasMap.py
get_terrain_display_settings
staticmethod
¶
get_terrain_display_settings(ras_project_path: Optional[Union[str, Path]] = None, *, terrain_name: Optional[str] = None, ras_object=None) -> Dict[str, Any]
Read persisted terrain display settings for one terrain layer.
Provide terrain_name when the project has multiple terrain layers.
The name match uses the RASMapper display name.
Source code in ras_commander/RasMap.py
set_terrain_display_settings
staticmethod
¶
set_terrain_display_settings(ras_project_path: Optional[Union[str, Path]] = None, *, terrain_name: Optional[str] = None, hillshade_enabled: Optional[bool] = None, hillshade_z_factor: Optional[float] = None, contour_enabled: Optional[bool] = None, contour_interval: Optional[float] = None, stitch_edges_enabled: Optional[bool] = None, stitch_tin_edges_enabled: Optional[bool] = None, level0_stitch_edges_enabled: Optional[bool] = None, level0_stitch_tin_edges_enabled: Optional[bool] = None, remove_stitch_rendering_enabled: Optional[bool] = None, ras_object=None) -> int
Write persisted terrain display settings in a project .rasmap file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Optional[Union[str, Path]]
|
Project folder, |
None
|
terrain_name
|
Optional[str]
|
Optional terrain layer display name. When omitted, all terrain layers are targeted. |
None
|
hillshade_enabled
|
Optional[bool]
|
Toggle |
None
|
hillshade_z_factor
|
Optional[float]
|
Set the hillshade Z factor where persisted. |
None
|
contour_enabled
|
Optional[bool]
|
Toggle |
None
|
contour_interval
|
Optional[float]
|
Set the contour interval where persisted. |
None
|
stitch_edges_enabled
|
Optional[bool]
|
Toggle |
None
|
level0_stitch_edges_enabled
|
Optional[bool]
|
Toggle |
None
|
remove_stitch_rendering_enabled
|
Optional[bool]
|
Toggle |
None
|
ras_object
|
RasPrj
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of XML attributes/elements modified. |
Source code in ras_commander/RasMap.py
set_update_legend_with_view
staticmethod
¶
set_update_legend_with_view(ras_project_path: Optional[Union[str, Path]] = None, *, checked: bool = True, include_results: bool = True, include_terrain: bool = True, include_geometry: bool = False, include_map_layers: bool = False, ras_object=None) -> int
Set RASMapper Update Legend with View for raster surface fills.
RASMapper persists this checkbox as RegenerateForScreen on
SurfaceFill XML elements. By default this targets result layers and
terrain layers, which are the surfaces most commonly used in inspection
screenshots.
Source code in ras_commander/RasMap.py
get_geometry_layer_bounds
staticmethod
¶
get_geometry_layer_bounds(geometry_hdf_path: Union[str, Path], *, layer_type: Optional[Union[str, Sequence[str]]] = None) -> Dict[str, Any]
Read HDF-derived bounds for a compiled geometry or geometry element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry_hdf_path
|
Union[str, Path]
|
Path to a compiled |
required |
layer_type
|
Optional[Union[str, Sequence[str]]]
|
Optional RASMapper child layer type. When omitted, bounds are computed from all recognized geometry coordinate datasets. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Bounds, source dataset paths, and point count. |
Source code in ras_commander/RasMap.py
get_geometry_feature_bounds
staticmethod
¶
get_geometry_feature_bounds(geometry_hdf_path: Union[str, Path], *, layer_type: str, feature_id: Optional[str] = None, feature_name: Optional[str] = None, feature_index: Optional[int] = None) -> Dict[str, Any]
Read HDF-derived bounds for a selected geometry feature.
Select the feature with feature_id from list_geometry_features(),
a display name, or a zero-based feature index.
Source code in ras_commander/RasMap.py
zoom_to_geometry_layer
staticmethod
¶
zoom_to_geometry_layer(ras_project_path: Optional[Union[str, Path]] = None, *, layer_id: Optional[str] = None, layer_type: Optional[Union[str, Sequence[str]]] = None, layer_name: Optional[str] = None, geometry_name: Optional[str] = None, geometry_number: Optional[str] = None, feature_id: Optional[str] = None, feature_name: Optional[str] = None, feature_index: Optional[int] = None, padding_fraction: Optional[float] = None, min_padding: float = 0.0, ras_object=None) -> Dict[str, Any]
Set CurrentView to the HDF-derived extent of a geometry element.
Select the target with a layer_id from list_geometry_layers() or
with a combination of parent geometry and child layer filters. Pass a
sequence to layer_type to zoom to the combined extent of multiple
geometry elements. To center the viewport on one feature inside a layer,
pass feature_id, feature_name, or feature_index; the layer
stays visible, but the viewport is centered on that feature. When
padding_fraction is omitted, layer views use 5% per-side padding and
feature views use 25% per-side padding, which expands the feature extent
by 50% overall for surrounding mesh context.
Source code in ras_commander/RasMap.py
open_rasmapper
staticmethod
¶
open_rasmapper(ras_project_path: Optional[Union[str, Path]] = None, *, rasmapper_exe_path: Optional[Union[str, Path]] = None, ras_version: Optional[str] = None, wait: bool = False, ras_object=None) -> subprocess.Popen
Launch standalone RasMapper.exe directly against the project .rasmap.
This avoids HEC-RAS menu automation. It is intended for inspection and
documentation workflows after the .rasmap view/layer state has been
configured.
Source code in ras_commander/RasMap.py
capture_rasmapper_snapshot
staticmethod
¶
capture_rasmapper_snapshot(*, pid: Optional[int] = None, output_path: Optional[Union[str, Path]] = None, delay_seconds: float = 1.0, timeout_seconds: float = 1800.0, poll_interval_seconds: float = 0.5) -> Optional[Path]
Capture a visible standalone RASMapper window to PNG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pid
|
Optional[int]
|
Optional RASMapper process id returned by |
None
|
output_path
|
Optional[Union[str, Path]]
|
Optional PNG output path. |
None
|
delay_seconds
|
float
|
Initial delay before capture polling starts. |
1.0
|
timeout_seconds
|
float
|
Maximum time to wait for a visible RASMapper window. Defaults to 1800 seconds because large projects can take many minutes to open in RASMapper. |
1800.0
|
poll_interval_seconds
|
float
|
Window polling interval. |
0.5
|
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Screenshot path, or |
Source code in ras_commander/RasMap.py
close_rasmapper
staticmethod
¶
Close visible standalone RASMapper windows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pid
|
Optional[int]
|
Optional process id to restrict which RASMapper window is closed. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of visible RASMapper windows sent a close message. |
Source code in ras_commander/RasMap.py
screenshot_model
staticmethod
¶
screenshot_model(ras_project_path: Union[str, Path], output_path: Optional[Union[str, Path]] = None, *, delay_seconds: float = 5.0, timeout_seconds: float = 1800.0, ras_version: Optional[str] = None, configure_layers: bool = True) -> Optional[Path]
One-call screenshot: backup rasmap, open RASMapper, capture, close, restore.
This is a convenience wrapper around open_rasmapper,
capture_rasmapper_snapshot, and close_rasmapper for the
common case of capturing a model's current RASMapper view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Union[str, Path]
|
Path to the .prj file (no init_ras_project needed). |
required |
output_path
|
Optional[Union[str, Path]]
|
Where to save the PNG. Defaults to
|
None
|
delay_seconds
|
float
|
Wait time for RASMapper to render before capture. |
5.0
|
timeout_seconds
|
float
|
Max time to wait for RASMapper window. |
1800.0
|
ras_version
|
Optional[str]
|
HEC-RAS version for finding RASMapper.exe. |
None
|
configure_layers
|
bool
|
If True (default), enable terrain and geometry layers in the .rasmap before opening RASMapper so the screenshot shows model content. The original .rasmap is restored afterward. |
True
|
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path to the saved PNG, or None if capture failed. |
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 | |
screenshot_model_gallery
staticmethod
¶
screenshot_model_gallery(models: List[Tuple[Union[str, Path], str]], output_dir: Union[str, Path], *, delay_seconds: float = 5.0, timeout_seconds: float = 1800.0, ras_version: Optional[str] = None) -> List[Dict[str, Any]]
Capture screenshots of multiple models into a gallery directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
List[Tuple[Union[str, Path], str]]
|
List of (project_path, label) tuples. Each project_path is a .prj file; label is used for the output filename. |
required |
output_dir
|
Union[str, Path]
|
Directory for all screenshots. |
required |
delay_seconds
|
float
|
Render wait per model. |
5.0
|
timeout_seconds
|
float
|
Max wait per model. |
1800.0
|
ras_version
|
Optional[str]
|
HEC-RAS version for finding RASMapper.exe. |
None
|
Returns:
| Type | Description |
|---|---|
List of dicts with keys
|
label, project_path, screenshot_path, success. |
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 | |
create_spatial_review_package
staticmethod
¶
create_spatial_review_package(ras_project_path: Optional[Union[str, Path]] = None, *, output_dir: Optional[Union[str, Path]] = None, geometry_number: Optional[str] = None, geometry_name: Optional[str] = None, layer_type: Optional[Union[str, Sequence[str]]] = None, layer_name: Optional[str] = None, feature_id: Optional[str] = None, feature_name: Optional[str] = None, feature_index: Optional[int] = None, terrain_name: Optional[str] = None, result_plan_name: Optional[Union[str, Sequence[str]]] = None, result_layer_name: Optional[Union[str, Sequence[str]]] = None, result_layer_type: Optional[Union[str, Sequence[str]]] = None, map_layer_name: Optional[Union[str, Sequence[str]]] = None, map_layer_type: Optional[Union[str, Sequence[str]]] = None, map_layer_category: Optional[Union[str, Sequence[str]]] = None, include_terrain: bool = True, include_results: bool = False, include_map_layers: bool = False, exclusive_geometry: bool = True, exclusive_terrain: bool = True, exclusive_results: bool = True, exclusive_map_layers: bool = True, update_legend_with_view: bool = True, zoom_to_layer: bool = True, padding_fraction: Optional[float] = None, min_padding: float = 0.0, capture_snapshot: bool = False, snapshot_filename: str = 'rasmapper_spatial_review.png', delay_seconds: float = 5.0, snapshot_timeout_seconds: float = 1800.0, snapshot_poll_interval_seconds: float = 0.5, close_after_capture: bool = True, viewport_width: Optional[int] = None, viewport_height: Optional[int] = None, dpi: Optional[int] = None, expanded_tree_paths: Optional[Sequence[str]] = None, ramp_id: Optional[str] = None, range_mode: Optional[str] = None, selected_layer: Optional[str] = None, result_profile: Optional[str] = None, render_mode: Optional[str] = None, basemap: Optional[str] = None, web_manifest_url: Optional[str] = None, rasmapper_exe_path: Optional[Union[str, Path]] = None, ras_version: Optional[str] = None, strict_preflight: bool = True, require_snapshot: bool = False, ras_object=None) -> Dict[str, Any]
Build a deterministic RASMapper spatial QA/QC evidence bundle.
The bundle records before/after .rasmap state, layer catalogs,
preflight checks, view/zoom metadata, and a findings template. It is
headless by default; pass capture_snapshot=True to launch standalone
RASMapper and add a screenshot on a Windows review machine. The
snapshot_timeout_seconds parameter defaults to 1800 seconds and can
be shortened for smoke tests or lengthened for very large projects.
Feature-focused views keep the full RASMapper layer visible and center
on the selected HDF feature, with 50% overall viewport expansion by
default for surrounding mesh and terrain context. Result and map layers
are hidden by default unless included or selected, which keeps review
figures deterministic.
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 | |
set_water_surface_render_mode
staticmethod
¶
set_water_surface_render_mode(mode: str = 'horizontal', reduce_shallow_to_horizontal: bool = True, use_depth_weighted_faces: bool = False, ras_object=None) -> bool
Set the water surface rendering mode in the RASMapper configuration file.
This modifies the .rasmap file to change how RASMapper renders water surfaces when generating raster outputs. The setting affects stored map exports and on-screen display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Rendering mode. Options: - "horizontal": Constant water surface elevation per mesh cell. Each cell displays a single, flat water surface. Faster rendering. - "sloping": Sloped water surface using 4-corner cell elevations. Basic interpolation within each cell. - "slopingPretty": Enhanced sloped mode using 8-point interpolation (4 corners + 4 face centers). Smoothest visualization. Supports optional reduce_shallow_to_horizontal and use_depth_weighted_faces flags. |
'horizontal'
|
reduce_shallow_to_horizontal
|
bool
|
When True, shallow cells fall back to horizontal rendering. Only applies to slopingPretty mode. Default: True. |
True
|
use_depth_weighted_faces
|
bool
|
When True, face contributions are weighted by depth. Only applies to slopingPretty mode. Default: False. |
False
|
ras_object
|
RasPrj
|
Optional RAS object instance. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an invalid mode is specified. |
FileNotFoundError
|
If the .rasmap file doesn't exist. |
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project(r"C:/Projects/MyModel", "7.0")
>>>
>>> # Set horizontal mode (flat WSE per cell)
>>> RasMap.set_water_surface_render_mode("horizontal")
>>>
>>> # Set basic sloping mode (4-corner interpolation)
>>> RasMap.set_water_surface_render_mode("sloping")
>>>
>>> # Set slopingPretty mode (8-point interpolation, smoothest)
>>> RasMap.set_water_surface_render_mode("slopingPretty")
>>>
>>> # slopingPretty with depth-weighted faces (HEC-RAS 6.31 style)
>>> RasMap.set_water_surface_render_mode(
... "slopingPretty",
... reduce_shallow_to_horizontal=True,
... use_depth_weighted_faces=True
... )
Notes
- Changes take effect the next time RASMapper generates raster outputs
- "horizontal" mode uses constant WSE per cell
- "sloping" mode uses 4-corner interpolation within each cell
- "slopingPretty" mode uses 8-point interpolation for smoothest results
- The original .rasmap file is modified in place (no backup created)
- The legacy mode name "sloped" is accepted as an alias for "slopingPretty"
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 | |
get_water_surface_render_mode
staticmethod
¶
Get the current water surface rendering mode from the RASMapper configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_object
|
RasPrj
|
Optional RAS object instance. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Rendering mode configuration with keys: - "mode": The rendering mode string — "horizontal", "sloping", or "slopingPretty" - "reduce_shallow_to_horizontal": bool, whether shallow cells fall back to horizontal (only for slopingPretty) - "use_depth_weighted_faces": bool, whether face contributions are depth-weighted (only for slopingPretty) Returns None if .rasmap file not found or mode not set. |
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project(r"C:/Projects/MyModel", "7.0")
>>> render_info = RasMap.get_water_surface_render_mode()
>>> print(f"Mode: {render_info['mode']}")
>>> # For slopingPretty, check flags:
>>> if render_info['mode'] == 'slopingPretty':
... print(f"Depth weighted: {render_info['use_depth_weighted_faces']}")
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 | |
RASMapper layers and associations¶
Import RasMap from ras_commander and call its static methods. Project-path
readers and initialized-project methods have different signatures: pass the
project path or ras_object accepted by the selected method rather than assuming
every method uses the global project.
| Operation | Input | Return / persisted effect |
|---|---|---|
parse_rasmap, layer-list methods |
.rasmap or project path, as documented below |
DataFrames or lists describing configured layers |
add_terrain_layer |
Existing terrain HDF | Registers terrain in .rasmap; does not create elevation data |
add_landcover_layer, add_soils_layer, add_infiltration_layer |
Classification sources and project | Created layer HDF path and registration |
| Classification polygon CRUD | Layer HDF, feature selectors and polygon/class data | GeoDataFrame; native polygon edits for authoring calls |
| Reference maps and basemaps | Existing vector file or supported basemap name | .rasmap registration, with method-specific path or Boolean return |
| Geometry association inspection/validation | Compiled geometry HDF or project | Association dictionaries or diagnostic DataFrames |
associate_geometry_layers |
Compiled geometry and terrain/classification paths | Updated geometry HDF path |
recompute_property_tables |
Geometry and selected native version | Updated HDF path after native property-table processing |
Native classification creation and polygon authoring require the HEC-RAS runtime supported by that method; reading a layer inventory is a separate operation. Check source CRS, project units and extent explicitly; see the spatial extent contract.
Before computing property tables, inspect and validate the compiled-HDF
associations. Afterwards inspect final cell properties, including Manning's n,
using the HDF API. An XML registration alone is insufficient.
RasProcess.validate_geometry_association_cli() on the
geometry completion page is a mutating native reference
validator, intended for disposable copies, not a read-only association check.
Examples with retained outputs: 233 — classification polygons and 931 — native terrain export.
Layer discovery and authoring¶
Class for parsing and accessing information from HEC-RAS mapper configuration files (.rasmap).
This class provides methods to extract paths to terrain, soil, land cover data, and various project settings from the .rasmap file associated with a HEC-RAS project. It also includes functionality to automate the post-processing of stored maps.
parse_rasmap
staticmethod
¶
Parse a .rasmap file and extract relevant information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rasmap_path
|
Union[str, Path]
|
Path to the .rasmap file. |
required |
ras_object
|
RasPrj
|
Optional RAS object instance. Retained for API compatibility; parsing does not require project state. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A single-row frame containing extracted information and explicit parse provenance. |
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
list_land_classification_layers
staticmethod
¶
list_land_classification_layers(ras_project_path: Union[str, Path], ras_object=None) -> pd.DataFrame
List semantic land-classification layers from a project .rasmap file.
Classifies each modern Type="LandCoverLayer" and legacy
Type="LandCover" entry as landcover, soils,
infiltration, or unknown using filename and selected parameter
semantics rather than exact display names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Union[str, Path]
|
Project folder, .prj file, or .rasmap file. |
required |
ras_object
|
RasPrj
|
Optional RasPrj object. Present for API consistency. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with one row per LandCoverLayer entry. |
Source code in ras_commander/RasMap.py
list_terrain_layers
staticmethod
¶
List terrain layers registered in a project .rasmap file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Union[str, Path]
|
Project folder, .prj file, or .rasmap file. |
required |
ras_object
|
RasPrj
|
Optional RasPrj object. Present for API consistency. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with one row per |
Source code in ras_commander/RasMap.py
list_landcover_layers
staticmethod
¶
List land-cover layers registered in a project .rasmap file.
Source code in ras_commander/RasMap.py
list_soils_layers
staticmethod
¶
List hydrologic soils layers registered in a project .rasmap file.
Source code in ras_commander/RasMap.py
list_infiltration_layers
staticmethod
¶
List infiltration layers registered in a project .rasmap file.
Source code in ras_commander/RasMap.py
list_land_classification_polygons
staticmethod
¶
list_land_classification_polygons(layer_hdf_path: Union[str, Path], ras_object=None) -> GeoDataFrame
List classification polygon overrides stored in a land-classification HDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_hdf_path
|
Union[str, Path]
|
Land-cover, soils, or infiltration sidecar HDF. |
required |
ras_object
|
RasPrj
|
Optional RasPrj object. Present for API consistency. |
None
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame with |
Source code in ras_commander/RasMap.py
add_land_classification_polygon
staticmethod
¶
add_land_classification_polygon(layer_hdf_path: Union[str, Path], polygon: Any, class_name: str, class_id: Optional[int] = None, variable_values: Optional[Mapping[str, Any]] = None, backup: bool = True, hecras_version: Optional[str] = None, ras_object=None) -> GeoDataFrame
Add one land-cover classification polygon through native RasMapperLib.
The class must already exist in the native land-cover sidecar; this
method does not create or remap raster classifications. HEC-RAS 6.x
and 7.0.x LC Type=LandCover sidecars are supported. HEC-RAS 5.x
callers should use the durable geometry Manning-region APIs instead.
A GeoSeries/GeoDataFrame must declare the same CRS as the sidecar.
Raw Shapely/GeoJSON coordinates are assumed to already use the sidecar
CRS. One-member, hole-free MultiPolygon input is normalized. True
multipart input and interior rings are rejected before mutation because
HEC-RAS 6.0 through 7.0.1 classification resampling cannot honor them.
The returned GeoDataFrame exposes classification_hdf_path,
backup_path, recompute_required, and class_update in
.attrs.
Source code in ras_commander/RasMap.py
update_land_classification_polygon
staticmethod
¶
update_land_classification_polygon(layer_hdf_path: Union[str, Path], polygon_index: int, polygon: Optional[Any] = None, class_name: Optional[str] = None, class_id: Optional[int] = None, variable_values: Optional[Mapping[str, Any]] = None, backup: bool = True, hecras_version: Optional[str] = None, ras_object=None) -> GeoDataFrame
Update one native 6.x/7.0.x land-cover polygon using an existing class.
Polygon and CRS validation follow
:meth:add_land_classification_polygon. The returned GeoDataFrame
exposes durable backup and recomputation metadata in .attrs.
Source code in ras_commander/RasMap.py
delete_land_classification_polygon
staticmethod
¶
delete_land_classification_polygon(layer_hdf_path: Union[str, Path], polygon_index: Optional[int] = None, class_name: Optional[str] = None, remove_unused_class: bool = False, backup: bool = True, hecras_version: Optional[str] = None, ras_object=None) -> GeoDataFrame
Delete native 6.x/7.0.x land-cover classification polygons.
The returned GeoDataFrame exposes durable backup, recomputation, and
removed-class metadata in .attrs. remove_unused_class=True
fails closed because the public native API cannot safely remove a
class; rebuild the sidecar classification table instead.
Source code in ras_commander/RasMap.py
add_landcover_layer
staticmethod
¶
add_landcover_layer(ras_project_path: Union[str, Path], source_path: Union[str, Path], classification_table: Union[DataFrame, str, Path], cell_size: float, source_field: Optional[str] = None, output_hdf_path: Optional[Union[str, Path]] = None, restrict_to_extent: Optional[Any] = None, layer_name: str = 'LandCover', buffer_distance: float = 0.0, hecras_version: Optional[str] = None, ras_object=None) -> Path
Create and register a land-cover classification layer for a RAS project.
restrict_to_extent may be a valid Shapely Polygon, a
MultiPolygon containing exactly one non-empty polygonal part, a
one-effective-geometry GeoSeries/GeoDataFrame, a four-value bounds
tuple/list, a bounds dict/object, or RasMapperLib.Extent.
buffer_distance is applied before raster bounds are derived, in
project CRS units, and defaults to 0.0. Callers are responsible for
supplying geometry in the project CRS. Empty, invalid, non-polygon, and
true multipart geometry inputs raise ValueError.
HEC-RAS authors the output TIFF and HDF through RasMapperLib. Version
5.x uses its byte-class legacy schema in a 32-bit helper process;
versions 6.x and newer use LandCoverComputable followed by
LandCoverLayer.Save() for native V2 normalization.
Source code in ras_commander/RasMap.py
add_soils_layer
staticmethod
¶
add_soils_layer(ras_project_path: Union[str, Path], gssurgo_path: Union[str, Path], cell_size: float, output_hdf_path: Optional[Union[str, Path]] = None, restrict_to_extent: Optional[Any] = None, buffer_distance: float = 0.0, hecras_version: Optional[str] = None, ras_object=None) -> Path
Create and register a soils layer from direct GSSURGO input.
For restricted extents, read whole polygons intersecting the buffered, grid-aligned bounds. Rasterize in tiles of at most 10 million cells; all tiles share one mapping and feed one native soils-layer computation.
restrict_to_extent accepts the same polygon and legacy bounds inputs
as :meth:add_landcover_layer. buffer_distance is applied in project
CRS units before raster bounds are derived and defaults to 0.0.
Multipart, empty, invalid, and non-polygon geometry inputs fail closed.
Source code in ras_commander/RasMap.py
add_infiltration_layer
staticmethod
¶
add_infiltration_layer(ras_project_path: Union[str, Path], infiltration_method: str = 'scs_curve_number', landcover_hdf_path: Optional[Union[str, Path]] = None, soil_layer_path: Optional[Union[str, Path]] = None, output_hdf_path: Optional[Union[str, Path]] = None, scs_reset_time_hours: Optional[float] = None, hecras_version: Optional[str] = None, ras_object=None) -> Path
Create and register an infiltration classification layer.
Source code in ras_commander/RasMap.py
get_rasmap_path
staticmethod
¶
Get the path to the .rasmap file based on the current project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_object
|
RasPrj
|
Optional RAS object instance. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path to the .rasmap file if found, None otherwise. |
Source code in ras_commander/RasMap.py
initialize_rasmap_df
staticmethod
¶
Initialize the rasmap_df as part of project initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_object
|
RasPrj
|
Optional RAS object instance. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame containing information from the .rasmap file. |
Source code in ras_commander/RasMap.py
get_terrain_names
staticmethod
¶
Extracts terrain layer names from a given .rasmap file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rasmap_path
|
Union[str, Path]
|
Path to the .rasmap file. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of terrain names. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the rasmap file does not exist. |
ValueError
|
If the file is not a valid XML or lacks a 'Terrains' section. |
Source code in ras_commander/RasMap.py
list_map_layers
staticmethod
¶
list_map_layers(ras_project_path: Optional[Union[str, Path]] = None, *, as_dataframe: Optional[bool] = None, ras_object=None) -> Union[pd.DataFrame, List[Dict[str, Any]]]
List top-level MapLayers entries in the RASMapper configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_project_path
|
Optional[Union[str, Path]]
|
Project folder, .prj file, or .rasmap file. If omitted, the active project is used. |
None
|
as_dataframe
|
Optional[bool]
|
Return a DataFrame when True. When omitted, explicit
|
None
|
ras_object
|
RasPrj
|
Optional RasPrj object instance. |
None
|
Returns:
| Type | Description |
|---|---|
Union[DataFrame, List[Dict[str, Any]]]
|
DataFrame with one row per top-level map layer, or legacy |
Union[DataFrame, List[Dict[str, Any]]]
|
|
Examples:
>>> from ras_commander import RasMap
>>> layers = RasMap.list_map_layers("/path/to/project")
>>> layers[["name", "type", "category", "filename"]]
Source code in ras_commander/RasMap.py
list_reference_map_layers
staticmethod
¶
list_reference_map_layers(ras_project_path: Optional[Union[str, Path]] = None, *, ras_object=None) -> pd.DataFrame
List shapefile and GeoJSON reference map layers in a project .rasmap.
Reference map layers are top-level MapLayers/Layer entries with
Type set to PointFeatureLayer, PolylineFeatureLayer, or
PolygonFeatureLayer.
Source code in ras_commander/RasMap.py
list_basemap_layers
staticmethod
¶
list_basemap_layers(ras_project_path: Optional[Union[str, Path]] = None, *, ras_object=None) -> pd.DataFrame
List WMS basemap layers registered in a project .rasmap.
Source code in ras_commander/RasMap.py
set_map_layer_visibility
staticmethod
¶
set_map_layer_visibility(ras_project_path: Optional[Union[str, Path]] = None, *, checked: bool = True, layer_name: Optional[Union[str, Sequence[str]]] = None, layer_type: Optional[Union[str, Sequence[str]]] = None, category: Optional[Union[str, Sequence[str]]] = None, exclusive: bool = False, ras_object=None) -> int
Toggle top-level RASMapper MapLayers entries.
Targets reference maps, basemaps, land-classification layers, or other
map-layer entries by name, type, or category. When no selector is
supplied, all map layers are targeted. Use exclusive=True with
checked=True to hide every non-matching map layer and show only the
layers needed for a figure.
Source code in ras_commander/RasMap.py
list_standard_basemap_layers
staticmethod
¶
List standard HEC-RAS 6.x basemap layer names supported for insertion.
Source code in ras_commander/RasMap.py
add_reference_map_layer
staticmethod
¶
add_reference_map_layer(ras_project_path: Optional[Union[str, Path]] = None, source_path: Optional[Union[str, Path]] = None, *, layer_name: Optional[str] = None, layer_type: Optional[Union[str, Sequence[str]]] = None, checked: bool = True, label_field: Optional[str] = None, label_config: Optional[Dict[str, Any]] = None, symbology: Optional[Dict[str, Any]] = None, replace_existing: bool = True, validate_geojson_wgs84: bool = True, ras_object=None) -> Path
Add or replace a shapefile/GeoJSON reference map layer in .rasmap.
GeoJSON sources are validated for RASMapper compatibility before the XML is changed. They must either declare WGS84/EPSG:4326 or have coordinate bounds consistent with WGS84 longitude/latitude.
Source code in ras_commander/RasMap.py
add_basemap_layer
staticmethod
¶
add_basemap_layer(ras_project_path: Optional[Union[str, Path]] = None, basemap_name: Optional[str] = None, *, checked: bool = True, replace_existing: bool = True, ras_object=None) -> Path
Add or replace a standard HEC-RAS basemap layer in .rasmap.
Use :meth:list_standard_basemap_layers to discover valid names.
Source code in ras_commander/RasMap.py
add_map_layer
staticmethod
¶
add_map_layer(layer_name: str, layer_file: Union[str, Path], layer_type: str = 'PolylineFeatureLayer', checked: bool = True, label_field: Optional[str] = None, label_config: Optional[Dict[str, Any]] = None, symbology: Optional[Dict[str, Any]] = None, replace_existing: bool = False, validate_geojson_wgs84: bool = True, ras_object=None) -> bool
Add a reference map layer to the RASMapper configuration file.
This legacy active-project method is retained for compatibility. New code
should use :meth:add_reference_map_layer, which returns the modified
.rasmap path and accepts an explicit project path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
Display name for the layer in RASMapper. |
required |
layer_file
|
Union[str, Path]
|
Path to GeoJSON, shapefile, or other supported file. |
required |
layer_type
|
str
|
RASMapper layer type: - "PolylineFeatureLayer" (default) - for lines (cross-sections) - "PolygonFeatureLayer" - for polygons - "PointFeatureLayer" - for points |
'PolylineFeatureLayer'
|
checked
|
bool
|
Whether layer is visible by default (True). |
True
|
label_field
|
Optional[str]
|
Field name to use for labels (e.g., "dss_path"). |
None
|
label_config
|
Optional[Dict[str, Any]]
|
Optional label configuration dict with keys: - "font_size": float (default 8.25) - "color": int (default -16777216 = black) - "position": int (0=center, 1=above, etc.) |
None
|
symbology
|
Optional[Dict[str, Any]]
|
Optional symbology configuration dict with keys: - "line_color": tuple (R, G, B, A) - "line_width": int - "fill_color": tuple (R, G, B, A) for polygons |
None
|
replace_existing
|
bool
|
Replace an existing reference layer with the same name. Default False preserves the historical append behavior. |
False
|
validate_geojson_wgs84
|
bool
|
Raise if a GeoJSON source is not WGS84-compatible. |
True
|
ras_object
|
RasPrj
|
Optional RasPrj object instance. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if layer was successfully added. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If .rasmap file doesn't exist. |
ValueError
|
If layer_file doesn't exist. |
Note
GeoJSON files MUST be in WGS84 (EPSG:4326) coordinate system for RASMapper to display them correctly. Always reproject your GeoDataFrame to WGS84 before saving:
gdf_wgs84 = gdf.to_crs("EPSG:4326") gdf_wgs84.to_file("output.geojson", driver="GeoJSON")
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project("/path/to/project", "7.0")
>>>
>>> # Add boundary conditions GeoJSON
>>> RasMap.add_map_layer(
... layer_name="Boundary Conditions",
... layer_file="boundary_cross_sections.geojson",
... label_field="dss_path"
... )
>>>
>>> # Add with custom symbology
>>> RasMap.add_map_layer(
... layer_name="BC Locations",
... layer_file="bc_points.shp",
... layer_type="PointFeatureLayer",
... symbology={"line_color": (255, 0, 0, 255), "line_width": 2}
... )
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 | |
remove_map_layer
staticmethod
¶
Remove a map layer from the RASMapper configuration file (.rasmap).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
Name of the layer to remove. |
required |
ras_object
|
RasPrj
|
Optional RasPrj object instance. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if layer was found and removed, False if not found. |
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project("/path/to/project", "7.0")
>>> RasMap.remove_map_layer("Boundary Conditions")
Source code in ras_commander/RasMap.py
ensure_rasmap_compatible
staticmethod
¶
Ensure .rasmap file is compatible with current HEC-RAS version.
For HEC-RAS 5.0.7 projects opened in HEC-RAS 6.x, the .rasmap file needs to be
upgraded to the 6.x format (adds
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ras_object
|
RasPrj
|
Optional RasPrj object instance (default: global ras). |
None
|
auto_upgrade
|
bool
|
If True, attempt automatic upgrade via GUI automation. If False, only detect version and return status without upgrading. |
True
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Status dictionary with keys: - 'status' (str): One of: - 'ready': .rasmap is already compatible - 'upgraded': Successfully upgraded .rasmap file - 'manual_needed': Upgrade required but auto-upgrade failed - 'message' (str): Human-readable status message - 'version' (str): Detected .rasmap version (e.g., "5.0.7", "7.0") |
Examples:
>>> from ras_commander import init_ras_project, RasMap
>>> init_ras_project("/path/to/project", "7.0")
>>>
>>> # Check compatibility (auto-upgrade if needed)
>>> result = RasMap.ensure_rasmap_compatible(auto_upgrade=True)
>>> print(result['status']) # 'ready', 'upgraded', or 'manual_needed'
>>>
>>> # Check only (no auto-upgrade)
>>> result = RasMap.ensure_rasmap_compatible(auto_upgrade=False)
Notes
-
Detection Logic:
- Parses .rasmap XML for
element - Checks for
section (present in 6.x, missing in 5.0.7) - Upgrade needed if version starts with "5." AND no
section
- Parses .rasmap XML for
-
Auto-upgrade Process (if auto_upgrade=True):
- Opens HEC-RAS with the project
- Uses GUI automation to click "GIS Tools" > "RAS Mapper"
- Waits for RASMapper to open (triggers .rasmap upgrade dialog)
- Closes RASMapper and HEC-RAS
- Verifies upgrade by re-parsing .rasmap
-
Integration:
- Called automatically by postprocess_stored_maps()
- Should be called before RasProcess.store_maps() workflows
- Always needed before RasProcess.store_maps()
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 | |
add_terrain_layer
staticmethod
¶
add_terrain_layer(terrain_hdf: Union[str, Path], rasmap_path: Union[str, Path], layer_name: str = 'Terrain', projection_prj: Optional[Union[str, Path]] = None, ras_object=None, relative_paths: bool = False) -> None
Add terrain layer to RASMapper configuration.
After creating terrain with RasTerrain.create_terrain_hdf(), register it in project's .rasmap file. This method creates the required XML structure in the Terrains section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terrain_hdf
|
Union[str, Path]
|
Path to terrain HDF file (e.g., "./Terrain/MyTerrain.hdf") |
required |
rasmap_path
|
Union[str, Path]
|
Path to .rasmap file to modify |
required |
layer_name
|
str
|
Display name for terrain layer (default: "Terrain") |
'Terrain'
|
projection_prj
|
Optional[Union[str, Path]]
|
Path to ESRI PRJ file. If provided, updates RASProjectionFilename element. Default: None (keeps existing). |
None
|
ras_object
|
RasPrj
|
Optional RasPrj object instance (default: global ras). |
None
|
relative_paths
|
bool
|
Include sibling and parent folders in relative terrain and projection references on the same drive. Default False keeps the existing descendant-only behavior. Different drives retain absolute references. Use True for relocatable cloned bundles. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If rasmap_path or terrain_hdf does not exist. |
ValueError
|
If rasmap file is not valid XML. |
Example
from ras_commander import RasMap
After creating terrain HDF¶
RasMap.add_terrain_layer( ... terrain_hdf="./Terrain/Terrain50.hdf", ... rasmap_path="./Project.rasmap", ... layer_name="Terrain50" ... )
With projection file¶
RasMap.add_terrain_layer( ... terrain_hdf="./Terrain/NewTerrain.hdf", ... rasmap_path="./Project.rasmap", ... layer_name="NewTerrain", ... projection_prj="./Terrain/Projection.prj" ... )
Notes
- Creates Terrains section if it doesn't exist
- Generates XML structure compatible with HEC-RAS 6.x:
near - Calculates relative path from .rasmap to terrain HDF
- If layer with same name exists, it will be replaced
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 | |
prune_event_condition_layers
staticmethod
¶
prune_event_condition_layers(keep_filenames: Sequence[Union[str, Path]], rasmap_path: Optional[Union[str, Path]] = None, ras_object=None, backup: bool = True) -> Dict[str, Any]
Remove stale event-condition layers from a cloned project.
HEC-RAS evaluates RASEventConditions layers during unsteady
preprocessing, including unchecked layers inherited from other plans
or source-project folders. A cloned breakout project can therefore
fail with Error processing event conditions even when its current
plan and unsteady-flow file are valid.
This method retains only exact filename matches, removes unmatched
event-condition layers anywhere in the .rasmap tree, writes
atomically, and validates exact readback. It never edits the referenced
HDF files. Pass an empty sequence to remove every event-condition
layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keep_filenames
|
Sequence[Union[str, Path]]
|
Exact layer |
required |
rasmap_path
|
Optional[Union[str, Path]]
|
Explicit |
None
|
ras_object
|
RasPrj
|
Optional initialized project object. |
None
|
backup
|
bool
|
Create a durable sibling backup before mutation. |
True
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
JSON-safe mutation evidence including removed/retained layers, |
Dict[str, Any]
|
backup path, and exact readback counts. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the |
FileExistsError
|
If the backup or atomic staging path exists. |
ValueError
|
If XML is invalid or a requested retained filename is absent before mutation. |
RuntimeError
|
If exact readback validation fails. |
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 | |
ensure_2d_encroachment_plan_layers
staticmethod
¶
ensure_2d_encroachment_plan_layers(plan_number_or_path: Union[str, int, float, Path], *, geom_hdf_path: Optional[Union[str, Path]] = None, checked: bool = True, ras_object=None) -> Path
Register editable 2D encroachment plan layers in the RASMapper Plans tree.
Adds or updates the plan-level RASEncroachments parent plus the
RASEncroachmentZones and RASEncroachmentPolygons child layers
used by RASMapper for 2D floodway authoring.
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 | |
Compiled geometry associations¶
Class for parsing and accessing information from HEC-RAS mapper configuration files (.rasmap).
This class provides methods to extract paths to terrain, soil, land cover data, and various project settings from the .rasmap file associated with a HEC-RAS project. It also includes functionality to automate the post-processing of stored maps.
associate_geometry_layers
staticmethod
¶
associate_geometry_layers(ras_project_path: Union[str, Path], geom_file: Union[str, Path], landcover_hdf_path: Optional[Union[str, Path]] = None, soil_layer_path: Optional[Union[str, Path]] = None, infiltration_hdf_path: Optional[Union[str, Path]] = None, terrain_hdf_path: Optional[Union[str, Path]] = None, sediment_soils_hdf_path: Optional[Union[str, Path]] = None, hecras_version: Optional[str] = None, ras_object=None) -> Path
Associate terrain / classification layers to a compiled geometry HDF.
This workflow delegates association writes to the selected HEC-RAS
RasMapperLib generation. It does not hand-write /Geometry
attributes.
soil_layer_path is a deprecated compatibility parameter through
v1.1.x. Hydrologic soils are not a geometry association: pass them to
:meth:add_infiltration_layer, then associate its
infiltration_hdf_path. Use sediment_soils_hdf_path only for the
distinct HEC-RAS SedimentSoilsFilename bed-material association.
Source code in ras_commander/RasMap.py
set_geometry_association
staticmethod
¶
set_geometry_association(geom_number: Union[str, Number, Path], terrain_hdf_path: Optional[Union[str, Path]] = None, landcover_hdf_path: Optional[Union[str, Path]] = None, infiltration_hdf_path: Optional[Union[str, Path]] = None, sediment_soils_hdf_path: Optional[Union[str, Path]] = None, hecras_dir: Optional[Union[str, Path]] = None, ras_object=None, validate: bool = True) -> Path
Associate terrain / classification layers directly on a geometry HDF.
Source code in ras_commander/RasMap.py
get_geometry_association
staticmethod
¶
get_geometry_association(geom_number: Union[str, Number, Path], hecras_dir: Optional[Union[str, Path]] = None, ras_object=None, resolve_paths: bool = True) -> dict
Read terrain / classification associations from a geometry HDF.
Source code in ras_commander/RasMap.py
list_geometry_associations
staticmethod
¶
list_geometry_associations(geom_number: Optional[Union[str, Number]] = None, ras_object=None) -> pd.DataFrame
Inventory live compiled-HDF associations for project geometries.
A layer registered in .rasmap is not necessarily associated with a
compiled geometry. This method reads each .g##.hdf directly and
returns one row per geometry, with every referencing plan collected in
plan_numbers. It does not cache association state on geom_df or
plan_df.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_number
|
Optional[Union[str, Number]]
|
Optional geometry number to select. When omitted, all project geometries are inspected. |
None
|
ras_object
|
RasPrj
|
Optional initialized :class: |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame described by the |
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 | |
validate_geometry_associations
staticmethod
¶
validate_geometry_associations(geom_number: Optional[Union[str, Number]] = None, required_layers: Sequence[str] = ('terrain', 'landcover'), require_existing_paths: bool = True, raise_on_failure: bool = True, ras_object=None) -> pd.DataFrame
Validate required compiled-geometry layer associations.
.rasmap registration is deliberately not accepted as proof of an
association. Use this before property-table generation, then inspect a
temporary plan HDF before compute and the final plan HDF afterward.
Source code in ras_commander/RasMap.py
| Python | |
|---|---|
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 | |
get_hdf_geometry_association
staticmethod
¶
get_hdf_geometry_association(hdf_path: Union[str, Path], resolve_paths: bool = True, include_2d_area_attrs: bool = True, ras_object=None) -> dict
Read /Geometry association attrs from a geometry, plan, or result HDF.
This is read-only and intended for QA/QC workflows that need to audit
terrain, land-cover, infiltration, or sediment bed-material links
already stored in HEC-RAS HDF artifacts. When
include_2d_area_attrs=True, the
two_d_area_terrain_associations list contains one record per named
2D flow-area group. Optional terrain fields are None when HEC-RAS
has not populated an area-level association.
Source code in ras_commander/RasMap.py
recompute_property_tables
staticmethod
¶
recompute_property_tables(ras_project_path: Union[str, Path], geom_file: Union[str, Path], hecras_version: Optional[str] = None, audit_mannings: bool = False, ras_object=None) -> Path
Recompute property tables with the selected native RASMapper version.
Completion is required for every geometry. When 2D flow areas are present, the native cell-volume and face-area table pairs must also be nonempty before this method returns. A complete 1D-only geometry has no 2D-array postcondition.
Set audit_mannings=True to require materially diverse, associated
final Manning values after the native command.
Modern native computation runs in an isolated process using the selected HEC-RAS installation's bundled HDF5 DLLs, with a 1,800-second timeout. That process runs RasMapperLib with the .NET Framework 4.7.2 target semantics of HEC-RAS's own hosts, so sorting ties in face profiles resolve as in HEC-RAS plan compute. Mutates the supplied geometry HDF in its existing CRS/units; use a disposable model copy. Process success does not replace the complete-geometry/table-pair checks or hydraulic QA.
Source code in ras_commander/RasMap.py
Layer validation¶
RasMapValidation performs format, CRS, raster and spatial checks and returns
validation results (or the Boolean convenience result from is_valid_layer).
These checks do not run the hydraulic solver.
Validation methods for HEC-RAS map layers.
Validates layer formats (GeoJSON, Shapefile, GeoTIFF, HDF), CRS/projections, raster metadata, spatial extents, and terrain/land cover layer configurations.
All methods are static and designed to be used without instantiation.
check_layer_format
staticmethod
¶
Check layer file format validity.
Validates: - File exists - Format is supported (GeoJSON, Shapefile, GeoTIFF, HDF) - File can be opened and read
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_file
|
Union[str, Path]
|
Path to layer file |
required |
Returns:
| Type | Description |
|---|---|
ValidationResult
|
ValidationResult with format validation |
Example
from ras_commander import RasMapValidation result = RasMapValidation.check_layer_format("terrain.tif") if result.is_valid: ... print(f"Format valid: {result.context.get('format')}")
Source code in ras_commander/RasMapValidation.py
| Python | |
|---|---|
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
check_layer_crs
staticmethod
¶
check_layer_crs(layer_file: Union[str, Path], expected_epsg: Optional[int] = None) -> ValidationResult
Check layer CRS/projection validity.
For GeoJSON files, enforces WGS84 (EPSG:4326) requirement. For other formats, checks against expected CRS if provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_file
|
Union[str, Path]
|
Path to layer file |
required |
expected_epsg
|
Optional[int]
|
Optional expected EPSG code (e.g., 4326 for WGS84) |
None
|
Returns:
| Type | Description |
|---|---|
ValidationResult
|
ValidationResult with CRS validation |
Source code in ras_commander/RasMapValidation.py
| Python | |
|---|---|
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
check_raster_metadata
staticmethod
¶
check_raster_metadata(layer_file: Union[str, Path], max_resolution: Optional[float] = 100.0, check_nodata: bool = True) -> List[ValidationResult]
Check raster metadata (resolution, extent, nodata).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_file
|
Union[str, Path]
|
Path to raster file |
required |
max_resolution
|
Optional[float]
|
Maximum acceptable resolution in meters (warn if coarser) |
100.0
|
check_nodata
|
bool
|
If True, check nodata percentage |
True
|
Returns:
| Type | Description |
|---|---|
List[ValidationResult]
|
Raster metadata validation results |
Source code in ras_commander/RasMapValidation.py
check_spatial_extent
staticmethod
¶
check_spatial_extent(layer_file: Union[str, Path], model_extent: tuple, min_coverage_pct: float = 50.0) -> ValidationResult
Check layer spatial extent vs model domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_file
|
Union[str, Path]
|
Path to layer file |
required |
model_extent
|
tuple
|
Model bounding box (minx, miny, maxx, maxy) |
required |
min_coverage_pct
|
float
|
Minimum coverage percentage (warn if below) |
50.0
|
Returns:
| Type | Description |
|---|---|
ValidationResult
|
Spatial extent validation result |
Source code in ras_commander/RasMapValidation.py
check_terrain_layer
staticmethod
¶
Check terrain layer configuration in rasmap file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rasmap_path
|
Union[str, Path]
|
Path to .rasmap file |
required |
layer_name
|
str
|
Name of terrain layer |
required |
Returns:
| Type | Description |
|---|---|
ValidationResult
|
Terrain validation result |
Source code in ras_commander/RasMapValidation.py
check_land_cover_layer
staticmethod
¶
Check land cover layer configuration in rasmap file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rasmap_path
|
Union[str, Path]
|
Path to .rasmap file |
required |
layer_name
|
str
|
Name of land cover layer |
required |
Returns:
| Type | Description |
|---|---|
ValidationResult
|
Land cover validation result |
Source code in ras_commander/RasMapValidation.py
check_layer
staticmethod
¶
check_layer(rasmap_path: Union[str, Path], layer_name: str, layer_type: Optional[str] = None) -> ValidationReport
Comprehensive layer validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rasmap_path
|
Union[str, Path]
|
Path to .rasmap file |
required |
layer_name
|
str
|
Name of layer to validate |
required |
layer_type
|
Optional[str]
|
Optional layer type ('Terrain', 'Land Cover', etc.) |
None
|
Returns:
| Type | Description |
|---|---|
ValidationReport
|
ValidationReport with all validation results |
Source code in ras_commander/RasMapValidation.py
is_valid_layer
staticmethod
¶
is_valid_layer(rasmap_path: Union[str, Path], layer_name: str, layer_type: Optional[str] = None) -> bool
Quick boolean check for layer validity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rasmap_path
|
Union[str, Path]
|
Path to .rasmap file |
required |
layer_name
|
str
|
Name of layer to validate |
required |
layer_type
|
Optional[str]
|
Optional layer type |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if layer is valid |
Source code in ras_commander/RasMapValidation.py
RASMapper geometry completion¶
Geometry completion creates native geometry-derived layers in an existing compiled geometry HDF. It is distinct from compiling geometry text, generating 2D computation points, and executing a hydraulic plan.
| API | Runtime | Inputs and outputs |
|---|---|---|
RasGeometryCompute.compute_geometry |
Windows, pythonnet, HEC-RAS 6.6+ | Geometry HDF and optional .rasmap; mutates HDF and returns GeometryCompleteResult |
Individual generate_* methods |
Same in-process native bridge | Selected edge lines, interpolation surface or flow paths; GeometryLayerResult |
validate_geometry, is_valid_geometry |
Native geometry validation | Diagnostics or Boolean convenience result |
| Reach-length and flow-path audits | See method-specific requirements below | Audit tables or FlowPathPolicyResult |
RasProcess.compute_geometry |
Windows or supported Linux/Wine subprocess path | Full native completion; dictionary with semantic validation and process evidence |
The full completion pipeline includes edge lines, the cross-section
interpolation surface and other geometry/property-table work. Flow paths are
separate: use generate_flow_paths() when needed. Completion may rebuild 2D
property tables and mutate more than one layer. Work on a project copy and
review diagnostics and resulting geometry before accepting it.
With the default overwrite=False, RasGeometryCompute.compute_geometry()
skips the pipeline if both edge lines and the interpolation surface already
exist. That path returns success=True without a separate skipped flag;
success alone does not prove the current call recomputed property tables.
Use RasGeometryCompute for the Windows in-process path; use the documented
RasProcess path for Linux/Wine completion. Do not infer that every in-process
method has a Wine equivalent. RasProcess.complete_geometry() is a deprecated
alias for compute_geometry().
On Windows with HEC-RAS 7.0.2, use RasProcess.compute_geometry() when the
in-process bridge fails with missing H5E_LOGFAIL_g. This was reproduced when
h5py loaded HDF5 2.0 before the vendor bridge. The subprocess isolates the vendor
DLLs; pass ras_version= with the exact executable path or installation
directory. This route completed the public BaldEagle geometry and matched the
7.0.1 control's three meshes dataset for dataset. It mutates geometry in place,
so use a project copy.
Ras.exe preprocessing requires a registered installation: an isolated 7.0.2
administrative image failed with an unregistered per-release RAS Mapper COM
class. After official installation and API TCU acceptance, Windows preprocessing
and unsteady plan computation passed with the
single-plan launch workaround.
The genuine 7.0.2 temporary HDF also passed guarded schema/write-readback checks;
Linux solve after mutation remains unqualified. Precipitation forcing, corner
preparation, and Linux/Wine execution were not qualified on 7.0.2 by these checks.
Read native output layers through HdfXsec.get_river_edge_lines(),
get_xs_interpolation_surface() and get_river_flow_paths() in the
HDF API. 234 — geometry completion
contains retained execution outputs.
In-process completion and diagnostics¶
Headless RASMapper geometry completion via pythonnet (Windows only).
generate_edge_lines
staticmethod
¶
generate_edge_lines(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, overwrite: bool = False, backup: bool = True, ras_object=None, hecras_version: Optional[str] = None) -> GeometryLayerResult
Generate HEC-RAS river edge lines into Geometry/River Edge Lines.
RASMapper's Create Edge Lines at XS Limits, run in-process. Unlike
HdfXsec.generate_river_edge_lines() (a pure-Python XS-endpoint
approximation used by get_1d_footprint()), this produces HEC-RAS's
own bank-line-anchored offset-curve edge lines and writes the group-level
Source Data Hash so HEC-RAS treats them as authoritative. Read the
result with HdfXsec.get_river_edge_lines().
Parameters¶
geom_hdf_path : str or Path
Geometry HDF (.g##.hdf), mutated in place.
rasmap_path : str or Path, optional
.rasmap for spatial reference; auto-resolved from ras_object
when omitted. Not required (geometry operations are coordinate-space).
overwrite : bool, default False
When False and the layer already exists, skip without recomputing.
backup : bool, default True
When overwriting an existing layer, first export it to a dated
.geojson.bak sidecar.
ras_object : RasPrj, optional
Used only to auto-resolve the .rasmap.
hecras_version : str, optional
Specific HEC-RAS version to bind the CLR to (e.g. "6.6").
Returns¶
GeometryLayerResult
Source code in ras_commander/RasGeometryCompute.py
generate_interpolation_surface
staticmethod
¶
generate_interpolation_surface(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, overwrite: bool = False, backup: bool = True, ras_object=None, hecras_version: Optional[str] = None) -> GeometryLayerResult
Generate the XS interpolation surface into
Geometry/Cross Section Interpolation Surfaces.
RASMapper's Compute XS Interpolation Surface, run in-process. HEC-RAS
self-ensures bank lines and edge lines first, so those layers are also
(re)generated as a side effect when out of date. Read the result with
HdfXsec.get_xs_interpolation_surface().
Parameters and returns mirror generate_edge_lines().
Source code in ras_commander/RasGeometryCompute.py
generate_flow_paths
staticmethod
¶
generate_flow_paths(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, overwrite: bool = False, backup: bool = True, ras_object=None, hecras_version: Optional[str] = None) -> GeometryLayerResult
Generate river flow paths into Geometry/River Flow Paths.
RASMapper's Create Flow Paths from XS Layout, run in-process. Read the
result with HdfXsec.get_river_flow_paths().
Manually defined or corrected flow paths must not be overwritten.
HEC-RAS keeps no cache hash for flow paths, so any regeneration
unconditionally replaces them. This method therefore defaults to
overwrite=False (skip when flow paths already exist). Set
overwrite=True to regenerate; with backup=True (default) the
existing flow paths are first exported to a dated .geojson.bak
sidecar. Use HdfXsec.get_river_flow_paths() to check for existing
flow paths before deciding.
Parameters and returns mirror generate_edge_lines().
Source code in ras_commander/RasGeometryCompute.py
compute_geometry
staticmethod
¶
compute_geometry(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, overwrite: bool = False, backup: bool = True, ras_object=None, hecras_version: Optional[str] = None) -> GeometryCompleteResult
Run the full RASMapper geometry-completion pipeline, in-process.
In-process equivalent of RasProcess.compute_geometry() and RASMapper's
"Compute Geometry" action (RasMapperLib RASGeometry.CompleteForComputations).
Generates bank lines, ineffective areas, blocked obstructions, edge lines,
the XS interpolation surface, storage-area / structure connectivity, and
2D property tables. Flow paths are not part of this pipeline (HEC-RAS
does not compute them during geometry completion); use
generate_flow_paths() for those.
Mutates the geometry HDF in place. No subprocess; Windows only (on Linux,
use RasProcess.compute_geometry()).
If h5py has loaded HDF5 2.0 into this process, vendor HDF.PInvoke can
fail with a missing H5E_LOGFAIL_g export (observed on HEC-RAS 7.0.2).
Use RasProcess.compute_geometry() on a separate project copy to
isolate the vendor DLLs from Python's native dependencies.
Parameters¶
geom_hdf_path, rasmap_path, ras_object, hecras_version
As in generate_edge_lines().
overwrite : bool, default False
When False and edge lines already exist, skip the whole pipeline.
backup : bool, default True
Back up existing edge lines to a dated .geojson.bak before an
overwrite.
Returns¶
GeometryCompleteResult
Source code in ras_commander/RasGeometryCompute.py
| Python | |
|---|---|
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
validate_geometry
staticmethod
¶
validate_geometry(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, ras_object=None, hecras_version: Optional[str] = None) -> 'object'
Run HEC-RAS geometry validation and return the diagnostics.
RASMapper's Validate Geometry (RasMapperLib
RASGeometry.ValidateGeometry + RASGeometry.Errors), run
in-process. Surfaces per-feature construction problems such as
self-intersecting edge lines, overlapping cross-section cut lines,
XS profile/polyline length mismatches, and bankline/flow-path
intersections — the issues that block edge-line and interpolation-surface
generation. One row per individual error.
Not to be confused with RasProcess.validate_geometry_association_cli(),
which validates terrain/land-cover association attributes, not per-feature
geometry construction.
Returns¶
GeoDataFrame
Columns: severity (INFO/WARNING/ERROR), level (raw RASMapper
level), layer, River, Reach, RS (parsed from the
feature name when it matches River, Reach (RS); else None),
feature (raw feature name), process, message, geometry
(currently None; reserved for the offending feature geometry). Empty
GeoDataFrame when no problems are found.
Source code in ras_commander/RasGeometryCompute.py
is_valid_geometry
staticmethod
¶
is_valid_geometry(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, ras_object=None, hecras_version: Optional[str] = None) -> bool
Return True when validate_geometry() reports no ERROR-level problems.
Convenience wrapper matching the is_valid_* validation-framework
naming. WARNING/INFO diagnostics do not fail the check.
Source code in ras_commander/RasGeometryCompute.py
audit_reach_lengths
staticmethod
¶
audit_reach_lengths(geom_hdf_path: Union[str, Path], flow_paths: str = 'existing_or_generate', tolerance: float = 0.5, keep_working_copy: bool = False, rasmap_path: Optional[Union[str, Path]] = None, ras_object=None, hecras_version: Optional[str] = None) -> 'object'
Audit XS reach (flow) lengths against the current cut lines and flow paths.
A 1D unsteady model requires LOB / channel / ROB reach lengths on every cross section; HEC-RAS measures those along the flow paths, so they go stale when cut lines move. This copies the whole project to a temporary location (the original is never modified), recomputes the reach lengths from the flow paths on the copy (RASMapper's "Update Reach Lengths on XSs"), and returns a per-XS before/after comparison so you can see which lengths have drifted.
The project (not just the geometry HDF) is copied because RASGeometry
needs the full project context to build the XS / river / flow-path
intersections that reach-length measurement depends on. For large projects
this copies the project directory; pass keep_working_copy=True to keep
the recomputed copy for inspection instead of deleting it.
Parameters¶
geom_hdf_path : str or Path
Geometry HDF to audit (must sit in its HEC-RAS project folder).
Not modified.
flow_paths : {'existing_or_generate', 'regenerate', 'existing'}
How to obtain flow paths on the copy before measuring lengths.
'existing_or_generate' (default) leaves existing flow paths untouched
(protecting manual edits) and generates them only when absent;
'regenerate' always regenerates them on the copy; 'existing' requires
them and raises if absent.
tolerance : float, default 0.5
Absolute length change (project units) above which a length is flagged
as changed.
keep_working_copy : bool, default False
Keep the temporary project copy (with recomputed lengths) instead of
deleting it. The copied geometry HDF path is returned in
report.attrs['working_copy'].
rasmap_path, ras_object, hecras_version
As in the generators.
Returns¶
GeoDataFrame
One row per cross section: River, Reach, RS,
len_{left,channel,right}_stored / _recomputed,
delta_{left,channel,right}, reach_end (bool; the
downstream-most XS of a reach whose recomputed lengths are undefined),
changed (bool), and geometry (the XS cut line). .attrs
carries a summary (changed_count, used_existing_flow_paths,
working_copy).
Raises¶
ValueError
If flow_paths is unrecognized, flow_paths='existing' but the
geometry has none, or the geometry has no cross sections.
Source code in ras_commander/RasGeometryCompute.py
| Python | |
|---|---|
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | |
assess_flow_path_policy
staticmethod
¶
assess_flow_path_policy(geom_hdf_path: Union[str, Path], tolerance_fraction: float = 0.01, *, join_upstream_xs: Optional[tuple[str, str, Union[str, float, int]]] = None, join_downstream_xs: Optional[tuple[str, str, Union[str, float, int]]] = None, review_segments_path: Optional[Union[str, Path]] = None, keep_working_copy: bool = False, rasmap_path: Optional[Union[str, Path]] = None, ras_object=None, hecras_version: Optional[str] = None) -> FlowPathPolicyResult
Recommend how a 1D join should handle overbank flow paths.
The original project is never modified. This method copies the whole project, regenerates RAS Mapper flow paths on the copy, recomputes every XS LOB/channel/ROB reach length, and compares the regenerated values to the stored source values.
regenerate_and_recompute is recommended only when every usable LOB
and ROB interval agrees with its stored value within
tolerance_fraction. Otherwise the conservative recommendation is
preserve_and_recompute_only_at_join_boundary. The conservative policy is
also selected when the source has no flow-path layer but stored LOB or
ROB lengths differ from the stored channel length.
Pass both join_upstream_xs and join_downstream_xs as
(river, reach, river_station) tuples after a provisional joined
geometry exists. The regenerated left/right flow paths are then clipped
between those adjacent cross sections and returned in
join_segments_gdf. The segments are review evidence for updating
only the new join interval; they do not modify the source or destination.
review_segments_path optionally writes those two segments as
GeoParquet. Existing files are never overwritten.
Source code in ras_commander/RasGeometryCompute.py
| Python | |
|---|---|
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | |
audit_main_channel_lengths
staticmethod
¶
audit_main_channel_lengths(geom_path: Union[str, Path], tolerance_fraction: float = 0.01, *, ras_object=None) -> 'gpd.GeoDataFrame'
Compare stored channel lengths to distances along the river line.
Accepts a plain-text .g## geometry or compiled .g##.hdf and does
not modify or clone it. This is an informative, cross-platform QA
check. main_channel_flagged is true for a non-terminal XS whose
stored and centerline-measured channel lengths differ by more than the
relative tolerance, or whose river-line intersection is invalid.
Source code in ras_commander/RasGeometryCompute.py
Subprocess completion and native association validation¶
validate_geometry_association_cli() mutates its target HDF; use an intentional
validation copy. It is not a read-only check.
Static class for automating HEC-RAS operations via RasProcess.exe CLI.
This class provides methods to: - Find RasProcess.exe in standard HEC-RAS installation paths - Generate stored maps using StoreAllMaps command - Configure stored maps in .rasmap files - Fix georeferencing issues in generated TIFs - Run on Linux via Wine (auto-detected, no code changes needed)
All methods are static and follow the ras-commander pattern of accepting an optional ras_object parameter for multi-project support.
Example (Windows - unchanged): >>> from ras_commander import init_ras_project, RasProcess >>> init_ras_project("path/to/project", "7.0") >>> results = RasProcess.store_maps( ... plan_number="01", ... output_folder="Maps", ... wse=True, ... depth=True, ... velocity=True ... )
Example (Linux with Wine): >>> from ras_commander import init_ras_project, RasProcess >>> # Auto-detects Linux and uses default Wine prefix >>> init_ras_project("/path/to/project", "7.0") >>> results = RasProcess.store_maps(plan_number="01") >>> >>> # Or configure Wine explicitly: >>> RasProcess.configure_wine( ... wine_prefix="/opt/hecras-wine", ... ras_install_dir="/opt/hecras-wine/drive_c/HEC-RAS/6.6" ... )
compute_geometry
staticmethod
¶
compute_geometry(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, ras_object=None, ras_version: str = None, timeout: int = 1800, semantic_stable_seconds: float = 10.0) -> Dict[str, Any]
Run HEC-RAS's headless geometry completion (RasProcess.exe CompleteGeometry).
This is the GUI-free equivalent of RASMapper's Compute Geometry action.
It wraps RASGeometry.CompleteForComputations(), the same pipeline the
RASMapper GUI runs, so it authors HEC-RAS's own River Edge Lines
("Create Edge Lines at XS Limits") and XS Interpolation Surface, plus
bank lines, ineffective areas, blocked obstructions, storage-area and
structure connectivity, and 2D property tables. The edge lines it produces
use HEC-RAS's bank-line-anchored offset-curve algorithm and carry the
group-level Source Data Hash, so HEC-RAS treats them as authoritative
and will not silently recompute them. (Flow paths are not part of this
pipeline.)
Platform guidance¶
This runs RasProcess.exe as a subprocess and works on both Windows
(native) and Linux (via Wine, auto-detected). On Windows, prefer
RasGeometryCompute.compute_geometry() — it runs the same pipeline
in-process via pythonnet (no subprocess), exposes each layer separately
(edge lines / interpolation surface / flow paths), and returns structured
ValidateGeometry diagnostics. This subprocess method remains the only
supported geometry-completion path for Linux/Wine execution.
Warning¶
This runs the entire geometry-completion pipeline (there is no narrower "just edge lines" RasProcess subcommand) and mutates the geometry HDF in place. Point it at a disposable copy unless you intend to complete the original geometry. On models with large 2D flow areas the pipeline also (re)builds 2D property tables and can take minutes.
Notes¶
HEC-RAS 7.0 exposes a ComputePropertyTables command, but its
ExecuteWith implementation raises NotImplementedException.
CompleteGeometry is the working command. Its CLI key is
GeomFilename (not the .NET property name GeometryFilename).
RasProcess.exe can report a native failure on either output stream
while returning exit code zero.
Parameters¶
geom_hdf_path : str or Path
Geometry HDF (.g##.hdf) to complete, mutated in place.
rasmap_path : str or Path, optional
.rasmap used to resolve the spatial reference. When None and a
ras_object is available, it is discovered via
RasMap.get_rasmap_path.
ras_object : RasPrj, optional
RAS project object used to locate the .rasmap and version-matched
RasProcess.exe when not supplied.
ras_version : str, optional
HEC-RAS release, executable path, or installation directory for the
RasProcess.exe lookup. An explicit path keeps completion on that runtime.
timeout : int, optional
Command timeout in seconds (default 1800).
semantic_stable_seconds : float, optional
Under Wine, terminate only the owned RasProcess.exe tree after
this invocation reports Completed Writing Geometry, changes the
geometry file, and leaves valid HDF semantics and size/mtime stable
for this many seconds (default 10). Preexisting tables cannot trigger
this fallback. Native Windows waits for normal process exit.
Returns¶
dict
rasprocess_path, command_args, return_code, stdout,
stderr, edge_lines_written, interpolation_surface_written,
completion_mode, semantic_validation, owned_process_cleanup,
success, error (None on success), and warnings.
Success requires a completed command, no native failure diagnostics,
and valid geometry completion artifacts in an updated HDF.
warnings lists each record HEC-RAS labels WARNING:, with its
detail lines joined by |; warnings do not fail the call.
Raises¶
FileNotFoundError If the geometry HDF or RasProcess.exe cannot be found.
Source code in ras_commander/RasProcess.py
| Python | |
|---|---|
1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 | |
complete_geometry
staticmethod
¶
complete_geometry(geom_hdf_path: Union[str, Path], rasmap_path: Optional[Union[str, Path]] = None, ras_object=None, ras_version: str = None, timeout: int = 1800, semantic_stable_seconds: float = 10.0) -> Dict[str, Any]
Deprecated alias for :meth:compute_geometry. Use compute_geometry.
Source code in ras_commander/RasProcess.py
validate_geometry_association_cli
staticmethod
¶
validate_geometry_association_cli(hdf_path: Union[str, Path], terrain_hdf_path: Optional[Union[str, Path]] = None, landcover_hdf_path: Optional[Union[str, Path]] = None, infiltration_hdf_path: Optional[Union[str, Path]] = None, sediment_soils_hdf_path: Optional[Union[str, Path]] = None, ras_version: str = None, timeout: int = 600, ras_object=None) -> Dict[str, Any]
Validate geometry association behavior against RasProcess.exe.
Warning
This method runs RasProcess.exe SetGeometryAssociation in-place
and mutates the supplied geometry HDF. It is a reference/validation
path only. Normal workflows should call
RasMap.associate_geometry_layers(...), which delegates to the
selected HEC-RAS generation's native geometry-association API and
validates its readback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hdf_path
|
Union[str, Path]
|
Existing geometry HDF to mutate and validate. |
required |
terrain_hdf_path
|
Optional[Union[str, Path]]
|
Optional terrain HDF to associate. |
None
|
landcover_hdf_path
|
Optional[Union[str, Path]]
|
Optional land-cover/Manning's n HDF. |
None
|
infiltration_hdf_path
|
Optional[Union[str, Path]]
|
Optional infiltration HDF. |
None
|
sediment_soils_hdf_path
|
Optional[Union[str, Path]]
|
Optional sediment bed-material soils HDF. |
None
|
ras_version
|
str
|
Optional HEC-RAS version for RasProcess.exe lookup. |
None
|
timeout
|
int
|
Command timeout in seconds. |
600
|
ras_object
|
RasPrj
|
Optional RasPrj object. Present for API consistency. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict containing command args, return code, stdout/stderr, |
Dict[str, Any]
|
before/after association attrs, expected attrs, mismatches, and |
Dict[str, Any]
|
|
Source code in ras_commander/RasProcess.py
| Python | |
|---|---|
1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 | |
Completion result records¶
GeometryLayerResult
dataclass
¶
Result of a single RasGeometryCompute layer-generation call.
Returned by RasGeometryCompute.generate_edge_lines() / generate_interpolation_surface() / generate_flow_paths(). Backward compatible with bool via bool.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Whether the layer was generated (or already present when skipped). |
layer |
str
|
Native HDF group written, e.g. "River Edge Lines". |
geom_hdf_path |
Path
|
Geometry HDF that was operated on. |
skipped |
bool
|
True when the layer already existed and overwrite=False. |
backup_path |
Optional[Path]
|
Path to the dated GeoJSON backup of pre-existing features, when one was written before overwriting. |
elapsed_seconds |
float
|
Wall-clock time for the generation call. |
error |
Optional[str]
|
Error message on failure, else None. |
Source code in ras_commander/ComputeResults.py
GeometryCompleteResult
dataclass
¶
Result of RasGeometryCompute.compute_geometry() (RASGeometry.CompleteForComputations).
Backward compatible with bool via bool. Distinct from GeometryPreprocessResult, which wraps HEC-RAS's numerical geometry preprocessor (a different pipeline).
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Whether the geometry-completion pipeline succeeded. |
geom_hdf_path |
Path
|
Geometry HDF that was completed. |
edge_lines_written |
bool
|
River Edge Lines present after the run. |
interpolation_surface_written |
bool
|
XS Interpolation Surfaces present after the run. |
flow_paths_written |
bool
|
River Flow Paths present after the run. |
backup_path |
Optional[Path]
|
Path to a dated GeoJSON backup written before overwriting, if any. |
elapsed_seconds |
float
|
Wall-clock time for the call. |
error |
Optional[str]
|
Error message on failure, else None. |
Source code in ras_commander/ComputeResults.py
FlowPathPolicyResult
dataclass
¶
Evidence used to select a safe 1D overbank flow-path policy.
RasGeometryCompute.assess_flow_path_policy() creates the evidence on an
isolated project copy. The two supported recommendations are
"regenerate_and_recompute" and
"preserve_and_recompute_only_at_join_boundary".
Attributes¶
geom_hdf_path
Original geometry HDF. It is never modified by the assessment.
recommended_policy
Conservative model-level recommendation. A preserve recommendation
on any reach controls the model-level value.
tolerance_fraction
Relative tolerance used to compare stored and regenerated lengths.
xs_metrics_df
Per-cross-section stored/regenerated length evidence.
reach_metrics_df
Per-river/reach policy and main-channel QA summary.
source_flow_paths_gdf
Flow paths present in the original geometry, if any.
regenerated_flow_paths_gdf
RAS Mapper flow paths generated on the isolated copy.
join_segments_gdf
Optional regenerated left/right flow-path segments clipped between the
two cross sections adjacent to a proposed join.
review_segments_path
GeoParquet path written for join_segments_gdf, when requested.
working_copy
Retained copied geometry HDF when keep_working_copy=True.
Source code in ras_commander/ComputeResults.py
Lower-level screenshot utilities¶
RasMap is the project-aware entry point above. For an already identified window
or dialog, RasScreenshot exposes capture and evidence-folder utilities. These
GUI calls require the documented Windows dependencies and desktop; listing saved
screenshots does not establish that a fresh capture succeeded.
Static class for capturing HEC-RAS window screenshots.
Uses Win32 Device Context (DC) and BitBlt to capture window pixels directly. Screenshots capture only the target window frame, not extra desktop pixels around it.
All methods are static and use the @log_call decorator.
capture_all_ras_windows
staticmethod
¶
Capture screenshots of ALL windows for a HEC-RAS process.
capture_dialog
staticmethod
¶
capture_dialog(title_pattern: str, output_path: Optional[Path] = None, exact_match: bool = False) -> Optional[Path]
Capture screenshot of a dialog window by title pattern.
capture_foreground
staticmethod
¶
Capture screenshot of the current foreground window.
capture_hecras_main
staticmethod
¶
Capture screenshot of main HEC-RAS window by process ID.
capture_menu_exploration
staticmethod
¶
Click a menu item and capture both before and after screenshots.
capture_window
staticmethod
¶
capture_window(hwnd: int, output_path: Optional[Path] = None, include_timestamp: bool = True, restore_if_minimized: bool = True, crop_to_visible_frame: bool = True) -> Optional[Path]
Capture a screenshot of a specific window by handle.
capture_with_delay
staticmethod
¶
capture_with_delay(hwnd: int, delay_seconds: float = 1.0, output_path: Optional[Path] = None) -> Optional[Path]
Capture window screenshot after a delay.
document_dialog
staticmethod
¶
Document a dialog window's controls and optionally capture screenshot.
get_screenshot_folder
staticmethod
¶
Get or create the screenshot output folder.
list_screenshots
staticmethod
¶
List all screenshots in the output folder.