Install the sf package on Ubuntu 20.04

Ggplot2 effective visualization.

Mauricio “Pachá” Vargas S.


January 17, 2023

R and Shiny Training: If you find this blog to be interesting, please note that I offer personalized and group-based training sessions that may be reserved through Buy me a Coffee. Additionally, I provide training services in the Spanish language and am available to discuss means by which I may contribute to your Shiny project.

I was unable to install the sf package on a clean Ubuntu 20.04 setup, and the problem is attributed to incompatible software versions. My workaround, instead of installing the package from source, was to install a precompiled binary package, but that depends on configuring a PPA for GDAL.

To add the PPA I run this command from bash

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt update && sudo apt upgrade

The last command updated some packages that sf sources required, which I installed with

sudo apt-get install libgdal-dev gdal-bin libproj15 libproj19 libproj-dev

Then I added a PPA maintained by CRAN, which contains binary R packages

sudo add-apt-repository
sudo apt update && sudo apt install r-cran-sf

And that’s it!