# DEM and Slope

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

Figure 23: Opening the “Processing Toolbox”.

Figure 24: Selecting the “Advanced interface” in the “Processing Toolbox”.

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 23).
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 24, 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 24 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 25: Warp tool

Figure 26: Setting the files and Source and Target SRS in the Warp Tool.

1. 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 25).

Figure 27: Selecting the Resampling tool in the Processing Toolbox.

1. Then double click “*Resampling”* under SAGA Grid – Tools to open the *Resampling* tool as shown in Figure 26.
2. 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 4 to determine which options to set for the *“Preserve Data Type”*, and the *“Interpolation Methods”* for scaling up and for scaling down.

Figure 28: Setting the Resampling tool options.

Table 4: Resampling settings based on the layer data type.

<table data-header-hidden><thead><tr><th></th><th width="150"></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>

1. 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 26) 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 26 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**.
2. 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 27).

Figure 29: Translate tool (convert raster format)

1. In the *“Translate”* box (see Figure 28) 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 29 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 30: Setting the Translate options.

Figure 31: Saving the translated raster as a PCRaster Raster File (\*.map).

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)*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://futurewater.gitbook.io/sphy-manual-3.0/manual/sphy-manual/build-your-own-sphy-model/dem-and-slope.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
