mapping¶
Result raster generation for HEC-RAS projects using the RASMapper engine.
Overview¶
The mapping module generates georeferenced raster files (GeoTIFF) from completed HEC-RAS plan results. With ras-commander 0.99.0 or newer it drives the canonical RasMap.store_all_maps(mode="selected") API, which deploys isolated RasStoreMapHelper.exe processes and preserves the correct water-surface render mode. ras-commander 0.98.2 remains supported through the serial compatibility path.
On Linux, RasProcess.exe runs under Wine. See the Linux/Wine Setup guide.
Supported Map Types¶
| Map Type | CLI Flag | Default | Description |
|---|---|---|---|
wse |
--wse/--no-wse |
On | Water Surface Elevation |
depth |
--depth/--no-depth |
On | Depth |
velocity |
--velocity/--no-velocity |
On | Velocity |
froude |
--froude |
Off | Froude Number |
shear_stress |
--shear-stress |
Off | Shear Stress |
depth_x_velocity |
--dv |
Off | Depth x Velocity |
depth_x_velocity_sq |
--dv-sq |
Off | Depth x Velocity² |
inundation_boundary |
--inundation-boundary |
Off | Inundation Boundary (shapefile) |
arrival_time |
--arrival-time |
Off | Arrival Time (hours, whole-simulation) |
duration |
--duration |
Off | Inundation Duration (hours, whole-simulation) |
percent_inundated |
--percent-inundated |
Off | Percent Time Inundated (whole-simulation) |
--recession is accepted for compatibility but ignored with a warning —
RasMapperLib has no recession map type, and only RasMapperLib-native outputs
are produced.
Whole-simulation map types¶
arrival_time, duration, and percent_inundated are computed over the
entire simulation — the --profile option does not apply to them. Their
filenames carry the --arrival-depth wet/dry threshold instead of the profile
name, e.g. Arrival Time (0.1ft hrs).tif. They work with any ras-commander
version: newer versions generate them natively via store_maps(); on older
versions ras2cng pre-injects the stored-map entries into the .rasmap
(restored afterwards) so the same StoreAllMaps run produces them.
Generating these types causes RasMapperLib to build a PostProcessing.hdf
cache that can exceed the plan HDF in size; ras2cng deletes it from the output
directory unless --keep-postprocessing is passed.
Local performance policy¶
The default DEFAULT_LOCAL_MAP_PERFORMANCE preset is tuned for local
processing on the 8-core, 31.8 GiB development workstation:
- memory-aware automatic helper selection (
max_workers=None); - enforced memory admission with an 8192 MiB / 25 percent reserve;
- one GDAL thread per helper to prevent nested oversubscription;
- a 64 MiB GDAL cache cap charged to every helper's memory estimate.
Only independent WSE, Depth, and Velocity products run concurrently. Large terrain estimates and products that require shared ordered state automatically use one helper. On the Spring River fixture, the measured estimate is about 11.2 GiB per helper, so this 31.8 GiB machine remains serial; a machine with more available memory can admit two or three map helpers without changing the call.
Use --map-workers 1 for a controlled serial comparison, or set the helper
ceiling, reserve, and cache explicitly:
ras2cng map model.prj ./maps \
--map-workers 2 \
--map-reserve-memory-mb 8192 \
--map-gdal-cache-mb 64
Python callers can provide the full typed policy without adding a second map function:
from ras_commander import StoreMapPerformanceOptions
from ras2cng import generate_result_maps
results = generate_result_maps(
"model.prj",
"maps",
performance=StoreMapPerformanceOptions(
max_workers=None,
reserve_memory_mb=8192,
gdal_cachemax_mb=64,
),
)
Render Mode¶
The --render-mode option controls how the water surface is rendered to raster grids. This is critical for pixel-perfect output — HEC-RAS 6.x's RasProcess.exe ignores the render mode from the .rasmap file, so ras-commander uses RasStoreMapHelper.exe to set the mode explicitly before generating maps.
| Mode | Flag | Description |
|---|---|---|
horizontal |
--render-mode horizontal |
Flat water surface within each mesh cell (default) |
sloping |
--render-mode sloping |
Interpolated sloping water surface |
slopingPretty |
--render-mode slopingPretty |
Sloping with depth-weighted face reduction (HEC-RAS 6.4+) |
If --render-mode is not specified, the mode is read from the project's .rasmap file (defaults to horizontal if not set).
# Generate maps with sloping render mode
ras2cng map /path/to/project /output/maps --render-mode sloping
# Archive with slopingPretty render mode (requires HEC-RAS 6.4+)
ras2cng archive /path/to/project ./archive/ --results --map --render-mode slopingPretty
Post-Processing Options¶
- Minimum depth threshold (
--min-depth): Set pixels below a depth threshold to NoData - WGS84 reprojection (
--wgs84): Reproject output rasters to EPSG:4326 using rasterio - Cloud Optimized GeoTIFF (
--cog): Convert output to COG usinggdal_translate
API Reference¶
ras2cng.mapping.MapResult
dataclass
¶
Result of map generation for a single plan.
Source code in ras2cng/mapping.py
ras2cng.mapping.generate_result_maps(project_path, output_dir, *, plans=None, profile='Max', wse=True, depth=True, velocity=True, froude=False, shear_stress=False, depth_x_velocity=False, depth_x_velocity_sq=False, inundation_boundary=False, arrival_time=False, duration=False, recession=False, percent_inundated=False, arrival_depth=0.0, terrain_name=None, ras_version=None, rasprocess_path=None, render_mode=None, min_depth=0.0, reproject_wgs84=False, convert_cog=False, timeout=10800, skip_errors=True, keep_postprocessing=False, performance=None)
¶
Generate result rasters for plans in a HEC-RAS project.
Uses the canonical RasMap.store_all_maps(mode="selected") API with
RasStoreMapHelper.exe to generate raw TIFs from completed plan HDF files.
With ras-commander 0.99.0 or newer, the default is memory-aware local auto
parallelism. ras-commander 0.98.2 retains its serial compatibility path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path
|
Path to .prj file or project directory |
required |
output_dir
|
Path
|
Directory for output raster files |
required |
plans
|
Optional[list[str]]
|
Plan IDs to process (e.g. ["p01", "p02"]). None = all with results |
None
|
profile
|
str
|
Output profile: "Max", "Min", or timestamp |
'Max'
|
wse
|
bool
|
Generate Water Surface Elevation rasters |
True
|
depth
|
bool
|
Generate Depth rasters |
True
|
velocity
|
bool
|
Generate Velocity rasters |
True
|
froude
|
bool
|
Generate Froude Number rasters |
False
|
shear_stress
|
bool
|
Generate Shear Stress rasters |
False
|
depth_x_velocity
|
bool
|
Generate Depth x Velocity rasters |
False
|
depth_x_velocity_sq
|
bool
|
Generate Depth x Velocity² rasters |
False
|
inundation_boundary
|
bool
|
Generate Inundation Boundary polygon (shapefile) |
False
|
arrival_time
|
bool
|
Generate Arrival Time rasters (hours; whole-simulation,
ignores |
False
|
duration
|
bool
|
Generate Duration rasters (hours; whole-simulation) |
False
|
recession
|
bool
|
Not supported — RasMapperLib has no recession map type; a warning is printed and the flag is ignored |
False
|
percent_inundated
|
bool
|
Generate Percent Time Inundated rasters |
False
|
arrival_depth
|
float
|
Wet/dry depth threshold (model vertical units) for arrival/duration/recession/percent_inundated (default: 0.0) |
0.0
|
terrain_name
|
Optional[str]
|
Specific terrain name from rasmap to use for mapping |
None
|
ras_version
|
Optional[str]
|
HEC-RAS version (auto-detected if None) |
None
|
rasprocess_path
|
Optional[Path]
|
Path to HEC-RAS install directory (for helper deployment) |
None
|
render_mode
|
Optional[str]
|
Water surface render mode: "horizontal", "sloping", or "slopingPretty". If None, reads from the .rasmap file (default: horizontal). |
None
|
min_depth
|
float
|
Minimum depth threshold for depth rasters (default: 0.0) |
0.0
|
reproject_wgs84
|
bool
|
Reproject output rasters to WGS84 |
False
|
convert_cog
|
bool
|
Convert output to Cloud Optimized GeoTIFF |
False
|
timeout
|
int
|
Per-plan timeout in seconds (default: 10800 = 3 hours) |
10800
|
skip_errors
|
bool
|
If True, log and continue past errors |
True
|
keep_postprocessing
|
bool
|
Keep the PostProcessing.hdf cache RasMapperLib creates for derived map types (can exceed the plan HDF in size). Default: delete it from the output directory. |
False
|
performance
|
Optional['StoreMapPerformanceOptions']
|
Optional ras-commander StoreMap performance policy. None
selects :data: |
None
|
Returns:
| Type | Description |
|---|---|
list[MapResult]
|
List of MapResult, one per processed plan |
Source code in ras2cng/mapping.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 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 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 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 | |