Import NASA DEM in GRASS GIS

Easy and quick using the r.in.nasadem addon

NASADEM

After nearly 20 years, a major update of the Shuttle Radar Topography Mission (SRTM) data was released in February this year. The product is called NASADEM, and consists of a combination of reprocessed SRTM data and auxiliary data from a variety of sources, including ASTER GDEM and Advanced Land Observing Satellite (ALOS) (Crippen et al. 2016). The dataset consists of three different layers: hgt, num and swb. The hgt layer is the void-filled DEM. The category values of the num layer indicate the number of DEM tiles used and the source of the data. And the swb layer is the updates SRTM water body data, with two classes; 0 for land and 255 for water. See for more information the NASADEM website or this comparison guide.

Importing in GRASS

GRASS GIS is one of the better tools to work with large high resolution raster data. And it has always been relatively easy to import raster data like the SRTM DEM into GRASS GIS (Neteler 2005). This applies to the NASADEM data as well. But with the r.in.nasadem add-on, developed by Markus Metz, it is just downright easy. The add-on imports all NASADEM tiles covering the current region, or region extents given with the region option into GRASS, and automatically patches the tiles together.

For the readers less familiar with GRASS GIS, the computational region is a cornerstone concept in GRASS GIS. The region defines the extent and resolution at which raster operations are carried out. Read the Wiki page for more information.

To import the NASADEM data for your area, you first need to install the r.in.nasadem addon. You can use the g.extension for this. Furthermore, to get access to the data, you’ll need to register at the Earthdata website. After registration, go to your user profile on the earthdata site and make sure the LP DAAC Data Pool and Earthdata Search applications are approved.

Now we can start with importing the data. The data comes in WGS 84 (EPSG 4326). Therefore, you need to import the data in a location with that reference coordinate system. If you don’t know what a location means in this context, read here about how a grass gis database is structured.

In your mapset, make sure to set the extent to match the region for which you want to download the data. Furthermore, set the resolution to 1 arc-second, which is the resolution of the NASADEM data. In this example, I’ll set the region to match a region in the central Oder valley in Poland.

You can run this directly from the command line, you can use the GUI, or using Python code. For the latter, you’ll need to import the PyGRASS module.

Bash

g.region n=52:38:40N s=51:08:02N w=15:36:05E e=18:30:02E res=0:00:01

GUI Go the Settings menu and select computational region > set region. Or you type g.region on the command line. Either way, you’ll get the g.region screen . Under the Bounds tab, fill in the upper, lower, left and right edges. In addition, select the Align region to resolution box to ensure the resolution will be exactly 1 arc-seconds.

g.region screen

Under the Resolution tab > 2D grid resolution fill in the target resolution (1 arc seconds).

g.region screen

And of course, don’t forget to push the Run button.

Python

from grass.pygrass.modules import Module
Module("g.region", n="52:38:40N", s="51:08:02N", w="15:36:05E", e="18:30:02E",
       res="0:00:01")

After installing the r.in.nasadem addon, you can find it under the Modules tab, in the Addons section. Alternatively, run r.in.nasadem on the command line or in the Console. Below, I’ll import the data for the region I defined above. To state the obvious, replace ‘your_username’ and ‘your_password’ with your own username and password of your account on EarthData.

Bash

r.in.nasadem output=NASAdem username=your_username password=your_password

Python

Module("r.in.nasadem", output="NASAdem", username="your_username",
       password="your_password")

GUI

r.in.nasadem screen

I already filled in the name of the output raster, NASAdem. Under the tab Optional you can probably leave the default NASADEM version as it is. Likewise, keep the NASADEM layer to hgt, unless you want to import one of the other two available layers. The user name and password are for the Earth data website mentioned above. You can leave the base URL as it is, unless you already have downloaded the data, in which case you have to point the addon to the right folder.

r.in.nasadem screen

As mentioned above, the r.in.nasadem imports all tiles required to cover this region, and patched them together. The resulting map likely covers a larger area than your study region. If you only want to keep the data for your study area, you can use r.mapcalc, like in the example below.

Bash

r.mapcalc "NASAdem = NASAdem" --overwrite

Python

Module("r.mapcalc", expression="NASAdem = NASAdem", overwrite=True)

So what did I do just there? Remember that the region defines the extent and resolution at which raster operations are carried out. So the output of any raster calculation is limited to the region extent. Furthermore, note that I use the -overwrite flag as GRASS GIS by default does not overwrite existing layers. There are other ways to do this, but this method is easy and results in raster layers with exactly the required extent and resolution. Did I already mention how much I like this concept of the computational region?

OK, and a mandatory image below created using the wxGUI 3D View Mode in GRASS. If you hover over the image, the colors representing the elevation are replaced by colors representing the different Corina Land Cover (CLC) categories (Copernicus 2019).

One thing about the SRTM is that in areas with a moderate to thick vegetation canopy, the elevation as provided by the SRTM is close to that of the canopy top rather than ground level (JPL n.d.; Weydahl et al. 2007; Orlandi et al. 2019). You can see this fairly clearly if you compare the elevation map with the CLC map (the green colors on the CLC map represent various forest types).

References

Copernicus. 2019. “Corine Land Cover (CLC) 2000, Version 20.” Dataset (raster, vector). European Environment Agency (EEA). https://land.copernicus.eu/pan-european/corine-land-cover/clc-2000.

Crippen, R., S. Buckley, P. Agram, E. Belz, E. Gurrola, S. Hensley, M. Kobrick, et al. 2016. “Nasadem Global Elevation Model: Methods and Progress.” ISPRS - International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences XLI-B4 (June): 125–28. https://doi.org/10.5194/isprsarchives-XLI-B4-125-2016.

JPL, NASA. n.d. “Shuttle Radar Topography Mission. Frequently Asked Quetions.” Shuttle Radar Topography Mission. Accessed June 27, 2020. https://www2.jpl.nasa.gov/srtm/faq.html.

Neteler, M. 2005. “SRTM and VMAP0 Data in OGR and GRASS.” GRASS Newsletter 3: 2–6.

Orlandi, Alex Gois, Osmar Abílio de Carvalho Júnior, Renato Fontes Guimarães, Edilson de Souza Bias, Douglas Corbari Corrêa, Roberto Arnaldo Trancoso Gomes, Alex Gois Orlandi, et al. 2019. “Vertical Accuracy Assessment of the Processed Srtm Data for the Brazilian Territory.” Boletim de Ciências Geodésicas 25 (4). https://doi.org/10.1590/s1982-21702019000400021.

Weydahl, D. J., J. Sagstuen, Ø B. Dick, and H. Rønning. 2007. “SRTM DEM Accuracy Assessment over Vegetated Areas in Norway.” International Journal of Remote Sensing 28 (16): 3513–27. https://doi.org/10.1080/01431160600993447.

Paulo van Breugel
Paulo van Breugel
Lecturer & researcher

My interests range from biodiversity and ecology to spatial data analysis. I am also what one could describe as a lifelong learner; I enjoy to learn new things and widen my horizon, both professionally and personally.

comments powered by Disqus
Previous