SatSure | Blog
Home » Satsure Blogs » Using the Digital Elevation Model (DEM) Dataset to Generate 3D Maps on SatSure Sparta

Using the Digital Elevation Model (DEM) Dataset to Generate 3D Maps on SatSure Sparta

Digital Elevation Model or DEM are gridded representations of terrain, with each cell’s value in the grid being its elevation. DEM data can be used in various applications, like the creation of relief maps, terrain analysis, and modeling water flow, amongst others.

There are multiple data sources for DEM available like SRTMASTERGMTED, etc.

Aster DEM 30m

On SatSure Sparta, the DEM data available is derived from ASTER 30m dataset and is available to download as PNG or raw tiffs at a sub-district level.

From a raw DEM input dataset, we can extract a variety of other derivative datasets. Some of which we will cover in this article are:

  1. Slope — It is the steepness or the degree of inclination of a particular surface. It is typically expressed as either a percentage or an angle.
  2. Aspect — It is the orientation of slope or the direction that the terrain is facing measured clockwise in degrees from 0 to 360, where 0 is north-facing, 90 is east-facing, 180 is south-facing, and 270 is west-facing.
  3. Hillshade — It is a 3D representation of a surface using the sun’s relative position to provide shading and depth to the image.

Initial Preparation:

The first step here is to download the raw tiff file from SatSure Sparta and importing that on QGIS or in your python code.

For this explanation, the region I have chosen is the Trimbakeshwar area of Maharashtra, and I have saved it by the name trim.tif

You can access the dataset by creating an account or logging in on SatSure Sparta, an Open Innovation Platform for AgTech and ClimateTech. (https://sparta.satsure.co/)

Trimbakeshwar, Nashik DEM representation on SatSure Sparta

Next, we need to open QGIS and drag and drop the image in the Layers tab.

Raw QGIS

Finally, we need to color the file. Here, I have used a Custom Colour ramp made from the same shades used in SatSure Sparta. You can make a custom color ramp or choose any of the pre-existing ones.

Steps to Process:

  1. In QGIS, double click — Layer properties
  2. Render type — Single-band pseudocolor
  3. Select color ramp
Raw Layer Color
Raw Colorized

Python

Import Modules

import os
import gdal
import rasterio
import matplotlib.pyplot as plt

Get DEM file and open it

with rasterio.open('trim.tif') as dataset:
dem=dataset.read(1)
plt.imshow(dem, cmap="magma")
plt.colorbar()
plt.show()

Output

Raw Python

Slope

Once we have our base layer in place, the next step is to perform Raster Analysis on it and extract different features. First, we will extract the Slope:

Steps

  1. Click on Raster > Analysis > Slope
Slope steps QGIS

2. Enable Slope Expressed as a percentage instead of degrees

Slope QGIS steps

Output:

Slope QGIS

Python

gdal.DEMProcessing('slope.tif', 'trim.tif', 'slope', options = '-p')
with rasterio.open('slope.tif') as dataset:
slope=dataset.read(1)
plt.imshow(slope, cmap="magma")
plt.colorbar()
plt.show()

Output:

Slope Python

Aspect

Similarly, we can also extract the Aspect.

Steps:

  1. Click on Raster > Analysis > Aspect
  2. Select the default values in the window that opens and click on Run

Output:

Aspect QGIS

Python

gdal.DEMProcessing('aspect.tif', 'trim.tif', 'aspect')
with rasterio.open('aspect.tif') as dataset:
aspect=dataset.read(1)
plt.imshow(aspect, cmap="magma")
plt.colorbar()
plt.show()

Output

Aspect Python

Hillshade

We also extract Hillshade the same way:

Steps:

Select Raster > Analysis > Hillshade

Hillshade QGIS

Python

gdal.DEMProcessing('hillshade.tif', 'trim.tif', 'hillshade')
with rasterio.open('hillshade.tif') as dataset:
hillshade=dataset.read(1)
plt.imshow(hillshade, cmap="magma")
plt.colorbar()
plt.show()

Output:

Hillshade Python

Customizing

The next step is changing colors and transparency to bring out the features. In our example, we made the transparency of the first 3 layers 60% so that we could see the layer beneath

Post this, we also colorized the Slope and Aspect layers using the same color map you see on SatSure Sparta. The resulting image is as below:

Final 2D Output

We can already see the different contours being visible. As is evident, the area in the south of the region seems to have a lot of hilly regions. The next step is to convert this to an actual 3D map!

3D Map

The following are the steps to take:

  1. Select View > New 3D Map View
Step 1 3D Map

Note: If you get an error saying:

3D view currently does not support unprojected coordinate reference systems (CRS).

Please switch the project’s CRS to a projected CRS

Go to Project > Properties

Set the CRS to any Projected CRS (as needed by your application)
I have used: WGS84 PROJECTION MILLER GEOPORTAIL

Then:

You can see a new window pop-up like this

Step 2 3D Map

2. Click on the Configure button in the toolbar

In the new window that opens:

  1. Change Type to DEM (Raster Layer)
  2. Change Elevation to your base DEM layer (trim in my case)
    (Optional parameters to change below. Change as needed)
  3. Increase vertical scale to 1.5
  4. Increase the tile resolution to 50 px (you can play around with this later)
  5. Scroll down, in Map tile resolution, select 128 px
  6. Increase the map screen error to 5 px

The resulting output will be something like this!

Final 3D Output

And there you have it!

That’s how you can ingest DEM data from SatSure Sparta. You can then use it to extract any of these derivatives like slope, aspect, or hillshade and generate amazing 3D visualizations!

Read more such articles on using SatSure Sparta and relevant use cases on https://sparta.satsure.co/#/index/blog.

Written by Arpit Kubadia, Junior Product Manager, SatSure. This story was first published on our Medium.

SatSure

Categories

Subscribe to our Email Newsletter