Skip to content

Instantly share code, notes, and snippets.

@klokan
Created January 29, 2015 01:13
Show Gist options
  • Save klokan/bfd4a07e8072ffae4bb6 to your computer and use it in GitHub Desktop.
Save klokan/bfd4a07e8072ffae4bb6 to your computer and use it in GitHub Desktop.
GDAL in Docker - stable GDAL with JP2KAK, MRSID and ECW: https://registry.hub.docker.com/u/klokantech/gdal/
FROM debian:7
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -qq update \
&& apt-get -qq -y --no-install-recommends install \
autoconf \
automake \
build-essential \
curl \
libcurl3-gnutls-dev \
libepsilon-dev \
libexpat-dev \
libfreexl-dev \
libgeos-dev \
libgif-dev \
libhdf4-alt-dev \
libhdf5-serial-dev \
libjpeg-dev \
liblcms2-dev \
liblzma-dev \
libnetcdf-dev \
libpcre3-dev \
libpng12-dev \
libpodofo-dev \
libpoppler-dev \
libproj-dev \
libspatialite-dev \
libsqlite3-dev \
libtbb2 \
libwebp-dev \
libxerces-c-dev \
libxml2-dev \
netcdf-bin \
poppler-utils \
python-dev \
unixodbc-dev \
unzip
ENV SDKS_URL http://login:password@private.url.com
ENV ECW_VERSION 3.3
ENV ECW_DATE 2006-09-06
ENV ECW_NAME libecwj2-$ECW_VERSION
ENV ECW_DIR /usr/local/src/$ECW_NAME
RUN curl -s $SDKS_URL/$ECW_NAME-$ECW_DATE.zip -o $ECW_DIR.zip \
&& unzip -q $ECW_DIR.zip -d /usr/local/src \
&& cd $ECW_DIR \
&& ./configure --prefix=/usr/local \
&& make \
&& make install
ENV MRSID_VERSION 9.1.0.4045-linux.x86-64.gcc44
ENV MRSID_NAME MrSID_DSDK-$MRSID_VERSION
ENV MRSID_DIR /usr/local/src/$MRSID_NAME
RUN curl -s $SDKS_URL/$MRSID_NAME.tar.gz | tar xz -C /usr/local/src \
&& cp $MRSID_DIR/Raster_DSDK/lib/libltidsdk.so* /usr/lib \
&& cp $MRSID_DIR/Lidar_DSDK/lib/liblti_lidar_dsdk.so* /usr/lib
ENV KAKADU_VERSION v7_2_2-01448C
ENV KAKADU_NAME $KAKADU_VERSION
ENV KAKADU_DIR /usr/local/src/$KAKADU_NAME
RUN curl -s $SDKS_URL/$KAKADU_NAME.zip -o $KAKADU_DIR.zip \
&& unzip -q $KAKADU_DIR.zip -d /usr/local/src \
&& sed -i 's/C_OPT += -m64/C_OPT += -m64 -fPIC/' \
$KAKADU_DIR/apps/make/Makefile-Linux-x86-64-gcc \
&& cd $KAKADU_DIR/coresys/make \
&& make -f Makefile-Linux-x86-64-gcc \
&& cd $KAKADU_DIR/apps/make \
&& make -f Makefile-Linux-x86-64-gcc all_but_hyperdoc \
&& cp $KAKADU_DIR/lib/Linux-x86-64-gcc/libkdu* /usr/lib
ENV GDAL_VERSION 1.11.1
RUN mkdir -p /usr/local/src \
&& curl -s http://download.osgeo.org/gdal/$GDAL_VERSION/gdal-$GDAL_VERSION.tar.gz \
| tar xz -C /usr/local/src
WORKDIR /usr/local/src/gdal-$GDAL_VERSION
RUN ./configure \
--prefix=/usr/local \
--without-libtool \
--with-ecw=/usr/local \
--with-epsilon \
--with-kakadu=$KAKADU_DIR \
--with-libkml \
--with-liblzma \
--with-mrsid=$MRSID_DIR/Raster_DSDK \
--with-mrsid_lidar=$MRSID_DIR/Lidar_DSDK \
--with-podofo \
--with-poppler \
--with-python \
--with-spatialite \
--with-threads \
--with-webp \
&& CXXFLAGS="-DKAKADU_VERSION=700" make \
&& make install \
&& ldconfig
@pksorensen
Copy link

Hi Petr Pridal, do you have any idea why using your gdal docker image that python bindings are not working.

(i am a newbie on python and just found a script i wanted to run and using your base image with gdal and --with-python I assumed I could do this)

Traceback (most recent call last):
  File "./rapideye_hist2sd.py", line 18, in <module>
    from osgeo import gdal
ImportError: No module named osgeo

@pksorensen
Copy link

Sorry, i was in the wrong container when i tried :) everything works as expected

@rotulet
Copy link

rotulet commented Jun 1, 2016

Hi, every time I tried to do a gdalinfo or gdal_translate onto an ecw file I get:

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_S_create
Aborted (core dumped)

I cannot attach an ecw file but I can send you one generating the error. But it seems to fail with any ecw.

Thanks.

@gasparakos
Copy link

If you have problem with ecw as rotulet and me see this: http://osgeo-org.1560.x6.nabble.com/ECW-support-on-Fedora-Linux-error-td4991388.html
If you in a hurry prefix your command with NCS_USER_PREFS=

@rbecheras
Copy link

rbecheras commented Dec 15, 2017

@rotulet I get the same error.

@gasparakos, thanks a lot! Your solution works for me:

NCS_USER_PREFS="" gdal_translate <...>

or

export NCS_USER_PREFS=""
gdal_translate <...>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment