James Croft

GDAL Hillshading

I generated this shaded image of Pendle Hill using GDAL and the Elevation dataset on AWS.

First I found the bounding box of the area using this tool.

-2.41081,53.814308,-2.185871,53.911186

Then I used GDAL to stitch together a Geotiff of the elevation data from S3.

GDAL v2 wasn’t available through Homebrew so I used a Docker container instead.

Watch out for the gotcha that the coordinate bounds (specified as projwin) are expected in a different order to the bounding box above.

The elevation.xml is a GDAL WMS that specifies how to get the tiles from S3, you can download it here.

  docker run  -v $(pwd):/gdal -w /gdal geographica/gdal2 \
    gdal_translate \
      -of GTiff  \
      -projwin -2.41081 53.911186 -2.185871 53.814308 \
      -projwin_srs EPSG:4326 \
      elevation.xml pendle.tif

Then I used the GDAL hillshade command to generate the shaded image. The -z flag is used to exaggerate the terrain slightly and -az is used to specify the location of the light source.

  docker run  -v $(pwd):/gdal -w /gdal geographica/gdal2 \
    gdaldem hillshade \
      -az 45 -z 8 -compute_edges \
      pendle.tif pendle-shaded.tif