# DEM and Slope

Before you continue with the next steps, make sure that you have opened the “Processing Toolbox” in QGIS (see Figure 23). Next make sure that you select the “Advanced interface” from the “Processing Toolbox” (see Figure 24).

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FLJL4TQ2du7tzC2CR2YDG%2Fafbeelding.png?alt=media&#x26;token=afd380de-72b7-4721-af8b-f9e54f9a9800" alt=""><figcaption><p>Figure 21: Opening the "Processing Toolbox".</p></figcaption></figure>

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FXPUqz0kmlknqSbET7sPy%2Fafbeelding.png?alt=media&#x26;token=e77f6018-8f8f-4800-9718-fb9fd786ca23" alt=""><figcaption><p>Figure 22: Selecting the "Advanced interface" in the "Processing Toolbox".</p></figcaption></figure>

Use your own DEM or otherwise the DEM provided in the database. You will need to project your DEM in the model’s projection and resample the DEM to model resolution and extent. You can do that using the following steps:

1. Drag the DEM inside the QGIS canvas;
2. Use the Warp tool in QGIS to reproject the DEM to the Coordinate Reference System (CRS) of your basin (EPSG:XXXXXX). This can be found under Raster 🡪 Projections 🡪 Warp (Reproject) (see Figure 25).
3. Within the Warp tool you need to select the “*Input file”*, the “*Output file”*, and the “*Target SRS”*. The “*Input file”* is the layer that you need to reproject, which is in this case the **dem**. The “O*utput file”* is the file to which you want to save the reprojected **dem** in GeoTiff format (\*.tif). Give it a useful name and save it in a directory that is useful. In the example of Figure 26, the reprojected dem is saved under the **SPHY/input/** directory with the name: **dem\_pr.tif**. Finally, it is important that you select the correct “*Target SRS*” (EPSG:XXXXX), which you defined in Section 5.1. In the example of Figure 26 it is EPSG:32737. Then click OK to do the reprojection. After the reprojection is finished click OK, and again OK, and finally Close.

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2Fr9fAydRT0HHFXSWa6IJ8%2Fafbeelding.png?alt=media&#x26;token=8f7a46d4-a098-4977-adf3-a244bce82900" alt=""><figcaption><p>Figure 23: Warp tool</p></figcaption></figure>

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2Fg1pil5PINIbimbru5gaN%2Fafbeelding.png?alt=media&#x26;token=9d0e813f-daea-41c5-8375-508277ee3fc8" alt=""><figcaption><p>Figure 24: Setting the files and Source and Target SRS in the Warp Tool.</p></figcaption></figure>

4. The next step involves resampling the projected dem from step 3) to the extent and spatial resolution of the **clone.map**. For this you need to type *“resampling”* in the “*Processing Toolbox”* search window (see Figure 27).

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FP00ISdiMdgmkFLmhGh7R%2Fafbeelding.png?alt=media&#x26;token=c1730f3e-a088-4ea2-befb-3449ad4e9c10" alt=""><figcaption><p>Figure 25: Selecting the Resampling tool in the Processing Toolbox.</p></figcaption></figure>

5. Then double click “*Resampling”* under SAGA 🡪 Grid – Tools to open the *Resampling* tool as shown in Figure 28.
6. Within this tool you need to select the *“Grid”* file that you want to resample, the *“Interpolation Methods”* for scaling up and for scaling down, the “*Output extent”*, the *“Cellsize”*, and the “*Grid”* to which you want to save the resampled file. You also need to check or uncheck the *“Preserve Data Type”* option. You can use Table 3 to determine which options to set for the *“Preserve Data Type”*, and the *“Interpolation Methods”* for scaling up and for scaling down.

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FAl8lOdUFFcMUCAXKMUXp%2Fafbeelding.png?alt=media&#x26;token=bf91a536-f423-42b1-a757-c1f485a981d1" alt=""><figcaption><p>Figure 26: Setting the Resampling tool options.</p></figcaption></figure>

*Table 8: Resampling settings based on the layer data type.*

<table data-header-hidden><thead><tr><th></th><th width="80"></th><th></th><th></th><th></th></tr></thead><tbody><tr><td>Layer data type</td><td>Preserve Data Type</td><td>Interpolation Method (scale Up)</td><td>Interpolation Method (scale Down)</td><td>Example layer</td></tr><tr><td>Continuous</td><td>No</td><td>Bilinear</td><td>Bilinear</td><td>DEM</td></tr><tr><td>Classified</td><td>No</td><td>Majority</td><td>Nearest neighbor</td><td>Landuse</td></tr></tbody></table>

7. Since the projected dem that we want to resample is continuous data, we select *“Bilinear Interpolation”* for both the interpolation methods, and we uncheck the *“Preserve Data Type”* option. For the *“Grid”* we select the projected dem from step 3). For the *“Output extent”* we use the layer extent (see Figure 28) of the **clone.map**. For the *“Cellsize”* (=cell length) you can fill in the value that you determined in Section 5.1. Then, save the resampled Grid as GeoTiff in the *“Grid”* in a useful directory. In the example of Figure 28 the file is saved as **dem\_res.tif** under the directory **SPHY/input/**. Finally, click Run to finish the resampling. If these steps are performed correctly, then your resampled **dem** should have the same extent and spatial resolution as your **clone.map**.
8. The final step involves converting the GeoTiff format to the PCRaster \*.map format. This can be done using the Translate function under Raster 🡪 Conversion 🡪Translate (Convert Format) (see Figure 29).

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2F8Q4fcruBzTLxHKGwfjwF%2Fafbeelding.png?alt=media&#x26;token=f9065dbc-c449-417b-8a1a-1817e48da6c2" alt=""><figcaption><p>Figure 27: Translate tool (convert raster format)</p></figcaption></figure>

9. In the *“Translate”* box (see Figure 30) make sure that you select the *“Input Layer”* (result from step 7) and set the *“Output Layer”*. The *“Output Layer”* should be save as PCRaster Raster File format (\*.map). In the example of Figure 31 we save it in the **SPHY\input\\** directory with the name **dem.map**. Finally click OK, and OK, and OK, and Close to finish this step.

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FddswZQ5r5dznb07Ugg85%2Fafbeelding.png?alt=media&#x26;token=c2d8a1ff-4ed3-48dc-9a8c-162e2e74780f" alt=""><figcaption><p>Figure 28: Setting the Translate options.</p></figcaption></figure>

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2F39oonPL1uOLkgouB2Bex%2Fafbeelding.png?alt=media&#x26;token=3cdff61e-08dd-4279-bbd7-d6455bdb3959" alt=""><figcaption><p>Figure 29: Saving the translated raster as a PCRaster Raster File (*.map).</p></figcaption></figure>

Now you should have the DEM in the model resolution and extent and in PCRaster format.

The slope map can be derived from the DEM using the [slope](http://pcraster.geo.uu.nl/pcraster/4.0.0/doc/manual/op_slope.html) command. This can be done in the Windows Command line window by typing:

*pcrcalc slope.map = slope(dem.map)*
