installing gdal and its python bindings on ubuntu 18

GDAL or the Geospatial Data Abstraction Library developed by the Open Source Geospatial Foundation (OSG) is one of the most important software libraries for geospatial analysis. You will find it at the heart of many other geospatial programs and applications. It is a command line tool built in C but also with Python bindings. GDAL supports raster formats while its daughter library OGR supports vector formats. Both are supported by the PROJ.4 library for projections. One of the major problems with GDAL is that it tends to be finicky with some installations.

 

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev python-dev python-gdal libevent-dev build-essential
sudo apt-get install libgdal1h

 

At this point the libgdal1h doesn’t show up. That’s because it’s from older repositories for previous releases of Ubuntu. Since it’s necessary for installing GDAL for python, we’ll just download straight from the package site.

 

wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gdal/libgdal1-dev_1.11.3+dfsg-3build2_all.deb
sudo dpkg -i *.deb

 

Afterwards we can then install the Python bindings. I recommend installing the Python binding inside a virtual environment just in case.

 

conda create --name gdal
conda activate gdal
pip install gdal