Shell scripts for working with NASA SRTM DEM data; gdaldem stylesheets for shaded relief maps; Mapnik stylesheets for contours; TileStache configuration for sandwich
Shell Python CartoCSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This package contains a set of shell scripts for working with NASA SRTM DEM data, gdaldem based stylesheets for creating shaded relief and/or hypsometric tinted maps, Mapnik stylesheets for making contours maps and a TileStache configuration for sandwiching or compositing the shaded relief and contour maps.

SRTM3 Hillshaded, Color Relief Contour Map

The aim of the project is to produce a free and open source repeatable workflow for visualising worldwide elevation data.

This project should be useful if you want to,

  • automate the download of SRTM3 data
  • produce a void filled single large GeoTIFF DEM from SRTM3 HGT tiles
  • produce hill shaded, slope shaded, hypsometric and/or contour maps
  • have contours loaded into a PostgreSQL/PostGIS database for use in a GIS
  • have a simple general purpose elevation layer/map (default style included)

All of the above use cases are accommodated for in these scripts.

The SRTM data has been released at varying resolution. SRTM3 refers to the near global 3 arc-second product and SRTM1 the higher resolution 1 arc-second product. SRTM1 was only released to the public in late 2014 and is not listed on the public directory yet at You can however download the files by navigating the website at


With the exception of stylesheets/ which is 3-clause BSD licensed, all files within this repository are licensed by the author, Andrew as follows.

To the extent possible under law, the person who associated CC0
with this work has waived all copyright and related or neighboring
rights to this work.

The SRTM data which these scripts are designed to use is in the public domain because it was solely created by NASA. NASA copyright policy states that "NASA material is not protected by copyright unless noted".

Running through the scripts


To run through all the steps provided by these script you will need,

wget unzip xz-utils gdal-bin postgresql-client postgis carto tilestache libmapnik|libmapnik2 fonts-sil-gentium-basic python-gdal

Downloading SRTM3 data

./scripts/ SRTM3_Region...

To determine the SRTM3_Region see the region map, in combination with the actual directory names for these regions.

You can list multiple regions as arguments or just one.

The coordinates refer to the bottom left corner of the tile, or expressed differently the tile is in the top right quadrant referred to by the coordinate.

Downloading SRTM1 data

Presently you need to navigate and manually download scenes via

Unzipping downloads

To unzip these downloads run,


If you want to keep these files for later reference, you may wish to re-compress using xz to save space using,


Which you can later uncompress again using,


Grunt work

If you have made it this far then all the data is prepared and ready for the real grunt work. The are two bits of processing we do. Preparing the vector contours and preparing the raster DEM. To create the final sandwiched map you will need to perform both steps, if not then you can just perform one.

Raster DEM processing

Creating a mosaic DEM

To avoid edge artefacts and to make the process simpler, we mosaic all those 1 x 1 degree tiles into a single continent mosaic using,

./scripts/ SRTM1|SRTM3 SRTM_Continent lon0 lon1 lat0 lat1

The last four parameters are the bounds we will use for the mosaic. You can only use integer values as they are simply used to select which individual .hgt tiles to glue together.

An additional processing step is also run as part of this script to fill the voids in the data. However you need to apply this patch to your script for this to work.

Hill shading and color relief (hypsometric tints)

./scripts/ SRTM1|SRTM3 SRTM_Continent

Keep in mind that the hypsometric tint values are defined in stylesheets/color-ramps/srtm-Continent-color-ramp.gdaldem.txt. In the first column you have the elevation value in meters. I've only created a color ramp specifically suited for the highest point in Australia. I'm not sure of the best approach for applying this on a global scale.

Vector contour processing

You will need a PostgreSQL database set up somewhere with the PostGIS extensions installed.

Then make sure you set your PG* environment variables, for example,

export PGDATABASE=srtm

then run,

./scripts/ SRTM1|SRTM3 lon0 lon1 lat0 lat1

This will convert the DEM into contours and load them into a PostgreSQL database.

After this you will need to run,

psql -f ./scripts/06-contour-level-pyramid.sql

This creates materialised tables of higher level contours (ie. 50m from the base 10m ones) and some other plumbing work.

Previewing the Mapnik style

If you have made it this far then you should be ready to start rending some maps!

There are two styles within the stylesheets directory. One for contours and one for the hill shaded color relief.

There is also a sample TileStache configuration for sandwiching these together into a single map layer.

The hill shaded color relief style should be ready to go.

The contour style needs to be configured with,


You can pass it parameters --host, --port, --dbname, --user, --password.

When you run it, it will copy the contours.template.mml into contours.mml and fill in the new file with your configuration.

You can then further run,

carto stylesheets/contours.mml > contours.xml

To convert it into a Mapnik XML stylesheet.

You could preview these independently with TileLite's litserv, or you could just run,

tilestache-server -c stylesheets/srtm3.tilestache.cfg

Alternatively you can generate some samples/previews of both the independent layers and the sandwiched layer using,


Be aware that for this you will need in your $PATH and the ImageMagick program convert.

There is a live preview of this sandwiched stylesheet.

Cleaning up

There are some files you can remove to save some space.

# remove the original zipped hgt files we downloaded from USGS
rm -rf

# remove the unzipped hgt files (if you want you can keep a .tar.xz)
rm -rf SRTM3

# if you no longer need the single large DEM but are just using the layers/
rm -rf SRTM3*.tiff