{ "cells": [ { "cell_type": "markdown", "id": "2d4c9e4d", "metadata": {}, "source": [ "# Download elevation data\n", "\n", "- Let's first import required libraries" ] }, { "cell_type": "code", "execution_count": 4, "id": "4eca1eca", "metadata": {}, "outputs": [], "source": [ "import elevation\n", "import pathlib" ] }, { "cell_type": "markdown", "id": "223cd8e8", "metadata": {}, "source": [ "## Elevation data for Helsinki" ] }, { "cell_type": "code", "execution_count": 11, "id": "16e1a881", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Nothing to be done for 'download'.\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Nothing to be done for 'all'.\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "cp SRTM1.vrt SRTM1.3d60b21ae94243ca9a7cac00371054a2.vrt\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "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\n", "rm -f SRTM1.3d60b21ae94243ca9a7cac00371054a2.vrt\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "find cache -size 0 -name \"*.tif\" -delete\n", "rm -f SRTM1.*.vrt\n", "rm -f -r spool/*\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n" ] } ], "source": [ "# Boundaries for Helsinki Region\n", "bounds = (24.538005, 60.078523, 25.206798, 60.350373)\n", "\n", "# Output filepath (get a full path, i.e. absolute)\n", "outfp = pathlib.Path(\"data/Helsinki/Helsinki-DEM.tif\").absolute()\n", "\n", "# Get the elevation data for the area\n", "elevation.clip(bounds=bounds, output=outfp)\n", "\n", "# Clean temp files\n", "elevation.clean()" ] }, { "cell_type": "markdown", "id": "e4e86997", "metadata": {}, "source": [ "## Elevation data for Brighton & Hove" ] }, { "cell_type": "code", "execution_count": 17, "id": "fd2da7c6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "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\n", "gunzip spool/N50/N50W001.hgt.gz 2>/dev/null || touch spool/N50/N50W001.hgt\n", "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\n", "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\n", "gunzip spool/N51/N51W001.hgt.gz 2>/dev/null || touch spool/N51/N51W001.hgt\n", "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\n", "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\n", "gunzip spool/N50/N50E000.hgt.gz 2>/dev/null || touch spool/N50/N50E000.hgt\n", "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\n", "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\n", "gunzip spool/N51/N51E000.hgt.gz 2>/dev/null || touch spool/N51/N51E000.hgt\n", "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\n", "rm spool/N51/N51W001.hgt spool/N51/N51E000.hgt spool/N50/N50W001.hgt spool/N50/N50E000.hgt\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "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\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "cp SRTM1.vrt SRTM1.2ba5efb2fd8f43d482dca91bff024859.vrt\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "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\n", "rm -f SRTM1.2ba5efb2fd8f43d482dca91bff024859.vrt\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n", "make: Entering directory '/home/hentenka/.cache/elevation/SRTM1'\n", "find cache -size 0 -name \"*.tif\" -delete\n", "rm -f SRTM1.*.vrt\n", "rm -f -r spool/*\n", "make: Leaving directory '/home/hentenka/.cache/elevation/SRTM1'\n" ] } ], "source": [ "# Boundaries for Brighton and its surroundings\n", "bounds = (-0.49975 , 50.7368697, 0.3469234, 51.3887287)\n", "\n", "# Output filepath (get a full path, i.e. absolute)\n", "outfp = pathlib.Path(\"data/Brighton/Brighton-DEM.tif\").absolute()\n", "\n", "# Get the elevation data for the area\n", "elevation.clip(bounds=bounds, output=outfp)\n", "\n", "# Clean temp files\n", "elevation.clean()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.8" } }, "nbformat": 4, "nbformat_minor": 5 }