Download elevation data#

  • Let’s first import required libraries

import elevation
import pathlib

Elevation data for Helsinki#

# Boundaries for Helsinki Region
bounds = (24.538005, 60.078523, 25.206798, 60.350373)

# Output filepath (get a full path, i.e. absolute)
outfp = pathlib.Path("data/Helsinki/Helsinki-DEM.tif").absolute()

# Get the elevation data for the area
elevation.clip(bounds=bounds, output=outfp)

# Clean temp files
elevation.clean()
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
make: Nothing to be done for 'download'.
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
make: Nothing to be done for 'all'.
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
cp SRTM1.vrt SRTM1.3d60b21ae94243ca9a7cac00371054a2.vrt
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 -projwin 24.538005 60.350373 25.206798 60.078523 SRTM1.3d60b21ae94243ca9a7cac00371054a2.vrt /home/hentenka/edu/r5edu/source/notebooks/data/Helsinki/Helsinki-DEM.tif
rm -f SRTM1.3d60b21ae94243ca9a7cac00371054a2.vrt
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
find cache -size 0 -name "*.tif" -delete
rm -f SRTM1.*.vrt
rm -f -r spool/*
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'

Elevation data for Brighton & Hove#

# Boundaries for Brighton and its surroundings
bounds = (-0.49975  , 50.7368697,  0.3469234, 51.3887287)

# Output filepath (get a full path, i.e. absolute)
outfp = pathlib.Path("data/Brighton/Brighton-DEM.tif").absolute()

# Get the elevation data for the area
elevation.clip(bounds=bounds, output=outfp)

# Clean temp files
elevation.clean()
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
curl -s -o spool/N50/N50W001.hgt.gz.temp https://s3.amazonaws.com/elevation-tiles-prod/skadi/N50/N50W001.hgt.gz && mv spool/N50/N50W001.hgt.gz.temp spool/N50/N50W001.hgt.gz
gunzip spool/N50/N50W001.hgt.gz 2>/dev/null || touch spool/N50/N50W001.hgt
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 spool/N50/N50W001.hgt cache/N50/N50W001.tif 2>/dev/null || touch cache/N50/N50W001.tif
curl -s -o spool/N51/N51W001.hgt.gz.temp https://s3.amazonaws.com/elevation-tiles-prod/skadi/N51/N51W001.hgt.gz && mv spool/N51/N51W001.hgt.gz.temp spool/N51/N51W001.hgt.gz
gunzip spool/N51/N51W001.hgt.gz 2>/dev/null || touch spool/N51/N51W001.hgt
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 spool/N51/N51W001.hgt cache/N51/N51W001.tif 2>/dev/null || touch cache/N51/N51W001.tif
curl -s -o spool/N50/N50E000.hgt.gz.temp https://s3.amazonaws.com/elevation-tiles-prod/skadi/N50/N50E000.hgt.gz && mv spool/N50/N50E000.hgt.gz.temp spool/N50/N50E000.hgt.gz
gunzip spool/N50/N50E000.hgt.gz 2>/dev/null || touch spool/N50/N50E000.hgt
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 spool/N50/N50E000.hgt cache/N50/N50E000.tif 2>/dev/null || touch cache/N50/N50E000.tif
curl -s -o spool/N51/N51E000.hgt.gz.temp https://s3.amazonaws.com/elevation-tiles-prod/skadi/N51/N51E000.hgt.gz && mv spool/N51/N51E000.hgt.gz.temp spool/N51/N51E000.hgt.gz
gunzip spool/N51/N51E000.hgt.gz 2>/dev/null || touch spool/N51/N51E000.hgt
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 spool/N51/N51E000.hgt cache/N51/N51E000.tif 2>/dev/null || touch cache/N51/N51E000.tif
rm spool/N51/N51W001.hgt spool/N51/N51E000.hgt spool/N50/N50W001.hgt spool/N50/N50E000.hgt
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
gdalbuildvrt -q -overwrite SRTM1.vrt cache/N50/N50E000.tif cache/N50/N50W001.tif cache/N60/N60E024.tif cache/N60/N60E025.tif cache/N51/N51W001.tif cache/N51/N51E000.tif
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
cp SRTM1.vrt SRTM1.2ba5efb2fd8f43d482dca91bff024859.vrt
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 -projwin -0.49975 51.3887287 0.3469234 50.7368697 SRTM1.2ba5efb2fd8f43d482dca91bff024859.vrt /home/hentenka/edu/r5edu/source/notebooks/data/Brighton/Brighton-DEM.tif
rm -f SRTM1.2ba5efb2fd8f43d482dca91bff024859.vrt
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'
make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'
find cache -size 0 -name "*.tif" -delete
rm -f SRTM1.*.vrt
rm -f -r spool/*
make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'