mapping¶
Result raster generation for HEC-RAS projects using RasProcess.exe.
Overview¶
The mapping module generates georeferenced raster files (GeoTIFF) from completed HEC-RAS plan results. It wraps RasProcess.store_maps() from ras-commander, which deploys RasStoreMapHelper.exe to set the correct water surface render mode via .NET reflection before calling StoreAllMapsCommand. This produces pixel-perfect rasters matching the RASMapper GUI output.
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 |
arrival_time |
--arrival-time |
Off | Arrival Time |
duration |
--duration |
Off | Duration |
recession |
--recession |
Off | Recession |
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, 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)
¶
Generate result rasters for plans in a HEC-RAS project.
Uses RasProcess.store_maps() with RasStoreMapHelper.exe to generate raw TIFs from completed plan HDF files.
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 |
False
|
duration
|
bool
|
Generate Duration rasters |
False
|
recession
|
bool
|
Generate Recession rasters |
False
|
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
|
Returns:
| Type | Description |
|---|---|
list[MapResult]
|
List of MapResult, one per processed plan |
Source code in ras2cng/mapping.py
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 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 | |