Skip to content

Instantly share code, notes, and snippets.

@glin glin/install-sf.sh
Last active Feb 13, 2020

Embed
What would you like to do?
Install sf from source on CentOS/RHEL 7
# Install sf from source on CentOS/RHEL 7. Tested with sf 0.8.0 on R 3.4 and 3.6.
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 http://download.osgeo.org/gdal/${VERSION}/gdal-${VERSION}.tar.gz
tar -xzvf gdal-${VERSION}.tar.gz
cd gdal-${VERSION}
./configure --prefix=/usr # install to /usr/lib. if --prefix isn't set, installs to /usr/local/lib by default
make
make install
ldconfig
# 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
You can’t perform that action at this time.