Skip to content

Instantly share code, notes, and snippets.

@abelcallejo
Last active March 25, 2024 11:35
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save abelcallejo/e75eb93d73db6f163b076d0232fc7d7e to your computer and use it in GitHub Desktop.
Save abelcallejo/e75eb93d73db6f163b076d0232fc7d7e to your computer and use it in GitHub Desktop.
Installing GDAL 3.2.1 on Amazon Linux 2

Installing GDAL 3.2.1 on Amazon Linux 2

gdal linux yum

As of this day, this is probably the only and fastest way of installing it.

Package requirements

Based from the GDAL and PROJ build requirements, here is the full list of required packages to install:

  • C++11 - cpp version 7.3.1
  • PROJ 6 - proj version 6.1.1
    • SQLite3 - sqlite3 version 3.7.17
    • libtiff - version 4.0
    • cmake - version 3.13.1

Installation of these packages are covered in the sections below. However, before you proceed with the installation, make sure you are already logged in to your EC2 Amazon Linux 2 via SSH. After logging in, you just need to issue some statements in the command-line.

1. Installation of required packages

Luckilly, we don't have to install everything from source. At least some can be installed through yum.

sudo yum install gcc-c++.x86_64 cpp.x86_64 sqlite-devel.x86_64 libtiff.x86_64 cmake3.x86_64 -y

2. Installation of PROJ

Installation from source, currently there's no other way but this.

cd /tmp
wget https://download.osgeo.org/proj/proj-6.1.1.tar.gz
tar -xvf proj-6.1.1.tar.gz
cd proj-6.1.1
./configure
sudo make
sudo make install

Important

Be careful not to install PROJ version 6.2.0 or newer because the one from the yum packages is only SQLite version 3.7.17. Installing PROJ version 6.2.0 would require installing SQLite version 3.11 which you may need to install from source and not with yum.

3. Installation of GDAL

Installation from source, currently there's no other way but this.

cd /tmp
wget https://github.com/OSGeo/gdal/releases/download/v3.2.1/gdal-3.2.1.tar.gz
tar -xvf gdal-3.2.1.tar.gz
cd gdal-3.2.1
./configure --with-proj=/usr/local --with-python
sudo make
sudo make install

Testing your installation

which gdalinfo; gdalinfo --version

It should show something like

/usr/local/bin/gdalinfo
GDAL 3.2.1, released 2020/12/29

finally

Comments and suggestions

Did I miss something? Are you having some troubles with the installed GDAL? Write them down as comments below. Let's help our selves and others at the same time.

@diego-gris
Copy link

I needed to install this for some R packages to work, sf, rnaturalearth, and leaflet

@ababaian, How/where did you install the R packages after getting all these dependencies installed? I am trying to run R on EMR but having trouble to install geospatial packages ('sf', 'terra', 'lidR').

@ababaian
Copy link

@diego-gris here's my docker where it's working (last I checked).

https://github.com/ababaian/palmid/blob/main/Dockerfile

@plazmakeks
Copy link

plazmakeks commented Jul 31, 2023

when configuring gdal i had to add the flags

--with-libpng --with-libpng-devel

to make gdal link with libpng and find some png symbols

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