Executing model algorithms iteratively
Models, like all QGIS algorithms, can be executed iteratively. Here, we will demonstrate this feature with one of the QGIS example models: DEMs_Clipped_to_Watersheds.model
. We will use two inputs, a DEM covering Taos, New Mexico and a watersheds polygon layer for the area. The elevation.tif
and watersheds.shp
sample data will be used.
The model has just one algorithm. It uses the Clip grid with polygon tool to clip the DEM to watersheds. There are 21 watersheds covering this area.
If the model is run normally, it will clip the DEM to the extent of all 21 watersheds and produce one output elevation raster. However, if the Iterate over this layer button () is clicked (see the following screenshot), the model will cycle through each feature in the watershed layer and output a DEM that covers each individual watershed. This will result in 21 individual elevation rasters. This sort of automation is very easy to generate and...