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:
gdal_merge.py -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 = np.ma.masked_less(s1,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))
lats = np.linspace(52,50,np.shape(s1m))
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:
P.S. The code is faster and has an acceptable reasolution on this scale with resolution=’i’, Full or high resolutions is really slow!
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.