1. Topographic analysis
1.1. Geospatial remapping
Pre-processing steps have prepared maps of domain-wide elevation, soil classes and vegetation types in .tif format. Here this data is mapped onto the Hydrologic Response Units SUMMA wil use.
Script 1 maps the MERIT Hydro DEM to HRUs through a zonal mean, resulting in the mean elevation of each HRU.
Script 2 maps the SOILGRIDS-derived USGS soil classes to HRUs through a zonal histogram, resulting in an occurrence count of each soil class in each HRU.
Script 3 maps the MODIS IGBP vegetation types to HRUs through a zonal histogram, resulting in an occurrence count of each vegetation type in each HRU.
These scripts result in new intersection files between the catchment and each of the three data sets. This information is needed to populate certain fields in SUMMA’s attribute .nc file.
1.2. QGIS analysis
This part of the workflow requires functions from the QGIS library. At the time of writing, there are multiple ways to achieve this:
Install the
qgispackage available on conda-forge and import QGIS functionality in a Python script as you would any other package. The Jupyter notebooks in this folder use this approach. Conda-forge: https://anaconda.org/conda-forge/qgisInstall a stand-alone QGIS application on the system and interact with it through a Python script. The Python scripts in this folder use a version of this approach, modified to work in an HPC environment. See: https://docs.qgis.org/3.16/en/docs/pyqgis_developer_cookbook/intro.html
1.2.1. Differences
Key differences between both approaches are as follows:
When QGIS is installed as a (Conda) package, all imports can occur at the top of the script. If Python interacts with a standalone QGIS install, importing the
processingtools needs to happen after the QGIS path is initialized (see scripts2and3).When QGIS is installed as a (Conda) package, there is no need to specify the plugin path where
processingcan be found. If Python interacts with a standalone QGIS install, it may be/is necessary to specify the path to the plugin folder. See e.g.: https://gis.stackexchange.com/questions/279874/using-qgis3-processing-algorithms-from-standalone-pyqgis-scripts-outside-of-gui
1.2.2. Code development
The notebooks were developed on a local machine with the QGIS package installed via Conda. The scripts were developed in an HPC environment were QGIS is available as a module (Copernicus cluster, Global Water Futures, Universisty of Saskatchewan, Canada). Below is an example of how this works:
# Load the required HPC modules
module load gcc qgis
# Run DEM intersection (does not need `processing` tools)
python 1_find_HRU_elevation.py
# Set the path to the QGIS plugin folder
export PYTHONPATH="$EBROOTQGIS/share/qgis/python/plugins:$PYTHONPATH"
# Run the soil and land intersection
python 2_find_HRU_soil_classes.py
python 3_find_HRU_land_classes.py
The scripts can easily be adapted to interact with a local QGIS install by specifying the plugin path before the import processing line (as shown in the link above).
1.3. Assumptions not included in control_active.txt
Code assumes we’re after a zonal histogram (soil and land classes) or a zonal mean (DEM). Changes to the code are needed to change these functions to something else if desired.
1.4. Control file settings
This section lists all the settings in control_active.txt that the code in this folder uses.
catchment_shp_path, catchment_shp_name: location and file name of the shapefile that contains the delineation of model elements.
parameter_dem_tif_path, parameter_dem_tif_name, parameter_soil_domain_path, parameter_soil_domain_name, parameter_land_mode_path, parameter_land_mode_name: locations of the geospatial parameter fields.
intersect_dem_path, intersect_dem_name, intersect_soil_path, intersect_soil_name, intersect_land_path, intersect_land_name: location where the files that contain the intersections between model elements and data need to be saved.