Skip to content

Instantly share code, notes, and snippets.

@glin
Last active May 10, 2022 14:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glin/404670e96226ff90c3029b4f43c5c7c9 to your computer and use it in GitHub Desktop.
Save glin/404670e96226ff90c3029b4f43c5c7c9 to your computer and use it in GitHub Desktop.
Install sf from source on CentOS/RHEL 7
# Install sf from source on CentOS/RHEL 7. Tested with sf 0.9-6 on R 3.6.3.
yum update -y
# Pre-reqs: gcc, gcc-c++, make
yum install -y gcc gcc-c++ make
# Install EPEL 7
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Install sf pre-reqs (note that proj-epsg is also required)
yum install -y geos-devel proj-devel proj-epsg udunits2-devel
# Install GDAL 2.x from source (replace VERSION with any other release from https://trac.osgeo.org/gdal/wiki/DownloadSource)
VERSION=2.3.2
curl -O https://download.osgeo.org/gdal/${VERSION}/gdal-${VERSION}.tar.gz
tar -xzvf gdal-${VERSION}.tar.gz
cd gdal-${VERSION}
./configure # Use --prefix to install to a custom location (defaults to /usr/local/lib)
make
make install
# Install sf
R -e 'install.packages("sf", repos = "https://cloud.r-project.org")'
# Test that the sf install worked
R -e 'library(sf)'
## > library(sf)
## Linking to GEOS 3.4.2, GDAL 2.3.2, PROJ 4.8.0
# Cleanup
cd ..
rm -rf gdal-${VERSION} gdal-${VERSION}.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment