A QGIS Processing Provider for accessing HEC-RAS model data through the ras-commander
library.
The RAS Commander QGIS Plugin provides hydraulic modelers and GIS analysts with a seamless interface within QGIS for accessing, analyzing, and visualizing HEC-RAS model data. The plugin leverages the existing ras-commander
Python library as its core engine and implements a modern QGIS Processing Provider architecture.
- Load Project Summary Tables (plan entries, geometry entries, unsteady entries, boundary conditions)
- Load Plan Parameters
- Load Runtime Statistics
- Load Volume Accounting
- Load 1D Cross-Sections
- Load 1D River Centerlines
- Load 1D Bank Lines
- Load 1D Hydraulic Structures
- Load 2D Mesh Area Perimeters
- Load 2D Mesh Cells
- Load 2D Breaklines
- Load 2D Boundary Condition Lines
- Load Pipe Conduits
- Load Pipe Nodes
- Load Maximum Water Surface Points
- Load Maximum Iteration Count Points
- Load Minimum Water Surface Points
- Delineate Fluvial-Pluvial Boundary
Windows users MUST run OSGeo4W Shell as Administrator for installation!
- Right-click OSGeo4W Shell → Run as administrator
- Failure to do so will cause plugin crashes or break QGIS
- This is the #1 cause of installation problems
- QGIS 3.22 or later (3.38+ Recommended)
- Administrator rights (Windows users)
- Right-click on the OSGeo4W Shell shortcut
- Select "Run as administrator"
- IMPORTANT: If you don't run as administrator, the installation will fail with permission errors or crash the plugin when loading in QGIS
Once in the administrator OSGeo4W Shell, you have two options:
Option A: Full Installation (Recommended if you have admin rights)
pip install ras-commander
Option B: No-dependencies Installation (If concerned about conflicts)
pip install ras-commander --no-deps
Why Administrator Rights are Required:
- QGIS Python packages are installed in protected system directories
- Without admin rights, pip cannot properly install packages to QGIS's Python environment
- Running without admin rights often results in partial installations that crash when the plugin loads
-
Identify the Python environment used by QGIS.
-
Install
ras-commander
usingpip
, again with the--no-deps
flag.pip install ras-commander --no-deps
If you encounter issues, try these steps in order:
-
If installed without administrator rights:
- Close QGIS completely
- Open OSGeo4W Shell as Administrator
- Reinstall ras-commander:
pip uninstall ras-commander -y pip install ras-commander
-
If QGIS libraries were accidentally upgraded:
# In Administrator OSGeo4W Shell pip install "numpy<2" --force-reinstall --no-deps pip install "h5py==3.7.0" --force-reinstall --no-deps
-
If plugin crashes on load:
- Ensure OSGeo4W Shell was run as Administrator during installation
- Check that ras-commander is properly installed:
pip show ras-commander
- Verify h5py compatibility in QGIS Python Console:
import h5py print(h5py.__version__)
Then copy the ras_commander_qgis
folder to your QGIS plugins directory and enable it in QGIS.
Typically located in C:\Users(Username)\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins
If you have no existing plugins, you may need to create the folder
After installation, you can verify the setup using the provided installation script:
# Run from within QGIS Python Console or OSGeo4W Shell
python install_script.py
This script will check:
- Python environment and version
- QGIS availability and version
- ras-commander installation and version
- h5py compatibility with QGIS environment
If you encounter h5py issues, the script provides a diagnose_h5py_issue()
function to help troubleshoot.
- Open the Processing Toolbox (Processing > Toolbox)
- Expand the RAS Commander provider
- Browse the available algorithms organized by category
- Double-click any algorithm to open its dialog
- Load Project Metadata: Start with "Load Project Summary Tables" to get an overview of your HEC-RAS project
- Load Geometry: Use the geometry algorithms to load cross-sections, mesh cells, etc.
- Load Results: Use the results algorithms to load water surface elevations and other computed values
- Analyze: Use analysis tools like "Delineate Fluvial-Pluvial Boundary" for advanced analysis
- Project Folders: For project summary data
- Geometry HDF Files (
*.g##.hdf
): For geometric data - Results HDF Files (
*.p##.hdf
): For simulation results
ras_commander_qgis/
├── __init__.py # Plugin entry point
├── plugin_main.py # Main plugin class
├── metadata.txt # Plugin metadata
├── icon.png # Plugin icon
└── processing/
├── __init__.py
├── provider.py # Processing provider
├── helpers.py # Utility functions
├── alg_load_project_summary.py
├── alg_load_cross_sections.py
└── ... (other algorithm files)
- Files:
snake_case
(e.g.,alg_load_mesh_cells.py
) - Classes:
PascalCase
(e.g.,LoadMeshCellsAlgorithm
) - Functions/Methods:
snake_case
(e.g.,process_algorithm
) - Variables:
snake_case
(e.g.,hdf_path
) - Constants:
UPPER_CASE_WITH_UNDERSCORES
- Create a new algorithm file in
processing/
following the naming convention - Implement the algorithm class inheriting from
QgsProcessingAlgorithm
- Add the import and algorithm instance to
provider.py
- Follow the existing patterns for error handling and user feedback
- QGIS: 3.22+ (3.38+ recommended for best compatibility)
- ras-commander: Latest version
- Python packages: pandas, geopandas (typically included with QGIS)
- QGIS 3.22-3.37: Fully supported
- QGIS 3.38+: Uses updated
QMetaType.Type
field constructors (recommended) - QGIS 3.42+: Tested and verified
Note: This plugin has been updated to use the modern QMetaType.Type
field constructors instead of the deprecated QVariant
types, ensuring compatibility with QGIS 3.38+ and future QGIS 4.0. For technical details, see the QGIS PyQGIS Developer Cookbook.
- Fork the repository
- Create a feature branch
- Follow the established coding style
- Add tests if applicable
- Submit a pull request
This project is licensed under the same terms as the ras-commander
library.
For issues related to:
- Plugin functionality: Open an issue in this repository
- ras-commander library: Refer to the ras-commander documentation
- QGIS Processing framework: Consult the QGIS documentation
This plugin is built on top of the excellent ras-commander
library and follows QGIS Processing framework best practices.