3  QGIS and gdal

3.1 QGIS

Linux Mint is a bit behind for all the GIS stuff. I had problems (ex.: open cloud optimized geotiff on internet) with a old version of gdal that comes with Mint.

To update to a newer version of gdal, install this PPA:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt update

Then, the latest version of QGIS:

wget -qO - https://qgis.org/downloads/qgis-2021.gpg.key | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import

sudo chmod a+r /etc/apt/trusted.gpg.d/qgis-archive.gpg

sudo add-apt-repository "deb https://qgis.org/ubuntu $(lsb_release -c -s) main"

sudo apt update

sudo apt install qgis qgis-plugin-grass

Not tested: use focal, because $(lsb_release -c -s) returns una as codename.

sudo add-apt-repository "deb https://qgis.org/ubuntu focal main"

Add the following to /etc/apt/sources.list.d/qgis.sources (replace Suites: kinetic based on your distro):

Types: deb deb-src
URIs: https://qgis.org/debian
Suites: kinetic
Architectures: amd64
Components: main
Signed-By: /etc/apt/keyrings/qgis-archive-keyring.gpg

3.2 GDAL

Download the latest version of gdal. Then configure and install:

tar xvf gdal-3.6.2.tar.gz
cd gdal-3.6.2
mkdir build
cd build

# Use which gdal-config to find the path and change the path accordingly
cmake .. -DCMAKE_PREFIX_PATH=/usr/bin -DCMAKE_BUILD_TYPE=Release
cmake --build .
cmake --build . --target install

Note, I needed to install libpsl-dev.

sudo apt-get install libpsl-dev

After installation, you might want to reinstall R packages that depend on GDAL, such as sf and terra.

# Force installation from source with build options
# This ensures packages are compiled from source code rather than using pre-compiled binaries

# Set repository (optional but recommended for consistency)
repos <- "https://cloud.r-project.org"

# Install packages from source with specific build options
install.packages(
  c("terra", "sf"),
  type = "source",
  repos = repos,
  configure.args = list(
    sf = "--with-proj-lib=/usr/local/lib/",
    terra = "--with-gdal-config=/usr/local/bin/gdal-config"
  ),
  INSTALL_opts = c("--no-multiarch", "--with-keep.source")
)

3.3 GEOS

See https://libgeos.org/usage/download/

3.4 See also