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.
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:
- 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.
- 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.
- Hillshade — It is a 3D representation of a surface using the sun’s relative position to provide shading and depth to the image.
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/)
Next, we need to open QGIS and drag and drop the image in the Layers tab.
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:
- In QGIS, double click — Layer properties
- Render type — Single-band pseudocolor
- Select color ramp
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()
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:
- Click on Raster > Analysis > Slope
2. Enable Slope Expressed as a percentage instead of degrees
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()
Similarly, we can also extract the Aspect.
- Click on Raster > Analysis > Aspect
- Select the default values in the window that opens and click on Run
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()
We also extract Hillshade the same way:
Select Raster > Analysis > Hillshade
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()
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:
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!
The following are the steps to take:
- Select View > New 3D Map View
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
You can see a new window pop-up like this
2. Click on the Configure button in the toolbar
In the new window that opens:
- Change Type to DEM (Raster Layer)
- Change Elevation to your base DEM layer (trim in my case)
(Optional parameters to change below. Change as needed)
- Increase vertical scale to 1.5
- Increase the tile resolution to 50 px (you can play around with this later)
- Scroll down, in Map tile resolution, select 128 px
- Increase the map screen error to 5 px
The resulting output will be something like this!
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.