SRTM DEM with Python/Basemap


i didn’t wrote anything in weeks, so it is time to change that. My goal for the next few months is to replace all my GIS stuff with little Python-scripts. So here is a simple one, which plots SRTM data with basemap and gdal. This is quite easy but a little bit slow!

First you need - surprise- SRTM-data (as GeoTIFFs). These are available for free in the net (even corrected versions!)

You can merge them to one file with this command: -o out.tiff SRTM*.tiff

The rest is easy. The can be read in Python with


into a numpy-array. You only need to create a basemap of your area. Then you need to mesh a grid within the basemap and plot the GeoTIFF using that grid with contourf()!

Here is the complete code:

import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import numpy as np
from osgeo import gdal

s1 = gdal.Open(‘srtm/thur.tif’).ReadAsArray()
s1m =,s1<0)

ThuringianMap = Basemap(llcrnrlon=6,

levels = np.arange(100,1000,25)
x = np.arange(10.3,11,0.1)
y = np.arange(50.4,51,0.1)

lons = np.linspace(10,12,np.shape(s1m)[1])
lats = np.linspace(52,50,np.shape(s1m)[0])
x, y = ThuringianMap(*np.meshgrid(lons, lats))
cs = ThuringianMap.contourf(x, y, s1m, levels,alpha=0.6)

And here is what it looks like. A map of Germany (with borders, coastlines and rivers) and a color-coded height map between the Harz-mountains and the Thuringian Forest:

Have fun!

P.S. The code is faster and has an acceptable reasolution on this scale with resolution=’i’, Full or high resolutions is really slow!

"Dancing Sundogs" Das heutige APOD. Sehr coole Sache. Wahrscheinlich richten sich die Eiskristalle im Elektrischen Feld neu aus. Das E-Feld ändert sich rapide bei Blitzentladungen!


I liked this video.

Seismic activity in Germay

A lot of small Earthquakes in Germany these days.

Seismic swarms at Voigtland Region

and ML4.6 Quake near the border to Holland.

Recent Swarm Earthquakes in Czech/Germany (Voigtlang Region)

Recent Swarm Earthquakes in Czech/Germany (Voigtlang Region)


Why do geologists love beer?

(via bonesinabox-deactivated20130217)

Me having a snack in Norway.

Me having a snack in Norway.

Grantic augen gneiss near Preikestolen (Norway).
Does anyone know how this structure could be formed?

Grantic augen gneiss near Preikestolen (Norway).

Does anyone know how this structure could be formed?