Running GDAL in Docker

The Geospatial Data Abstraction Library (GDAL – https://www.gdal.org/) is a commonly used library for handling geospatial data formats. It’s possible to install this software on your system but as an alternative you can run GDAL from Docker (https://www.docker.com/) and avoid the installation hassle.

In the following example a TIF file with height information is reprojected from the Dutch coordinate system (Amersfoort / RD New) to WGS84 using the GDAL tools ‘gdalinfo’ and ‘gdalwarp’. Docker image ‘geodata/gdal’ is used.

This example demonstrates running console programs from Docker and shows how the Docker mounting option (-v) works.

1] download a TIF image:

$ wget http://www.rijkswaterstaat.nl/apps/geoservices/geodata/dmc/ahn2_05_int/geogegevens/raster/01_09/i09bz1.tif

2] Inspect input image

Let’s inspect the image with ‘gdalinfo’, projection is ‘Amersfoort / RD New’:

$ docker run -v $(pwd):/data  geodata/gdal gdalinfo /data/i09bz1.tif

Driver: GTiff/GeoTIFF

Files: /data/i09bz1.tif

Size is 10000, 12500

Coordinate System is:

PROJCS["Amersfoort / RD New"

NB: If you’re running Docker on Windows the variable for current directory (‘$(pwd)’)  does not work. Do something like this instead:

$ docker run -v d:/gisdata/images:/data  geodata/gdal gdalinfo /data/i09bz1.tif

3] Reproject the image

Reproject with gdalwarp (input=i09bz1.tif, output=i09bz13857.tif, target projection is EPSG:3857):

$ docker run -v $(pwd):/data  geodata/gdal gdalwarp -t_srs EPSG:3857 /data/i09bz1.tif /data/i09bz13857.tif

4] Inspect output image

Run gdalinfo again and see the projection is changed to ‘WGS 84 / Pseudo-Mercator’

$ docker run -v $(pwd):/data  geodata/gdal gdalinfo /data/i09bz13857.tif

Driver: GTiff/GeoTIFF

Files: /data/i09bz13857.tif

Size is 10095, 12600

Coordinate System is:

PROJCS["WGS 84 / Pseudo-Mercator"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s