Skip to content

Instantly share code, notes, and snippets.

@Hua-Zhou
Last active February 4, 2022 17:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hua-Zhou/6c11babe35437ce1ea8e4893a14d07c8 to your computer and use it in GitHub Desktop.
Save Hua-Zhou/6c11babe35437ce1ea8e4893a14d07c8 to your computer and use it in GitHub Desktop.
install R package `sf` on CentOS 7
Installation `sf` package in R on CentOS fails because `sf` requires gdal >v while CentOS yum install gives gdal v1.11.4.
1. Install Sqlite3 from source
```bash
configure
make -j4
sudo make install
```
Now system has two versions of Sqlite3 installed. One (old version) by yum, the other (most updated one) we just installed.
Executable is installed in: /usr/local/bin/sqlite3
Libraries have been installed in: /usr/local/lib
Header files are installed in: /usr/local/include
Manual is installed in: /usr/local/share/man/man1
2. Install Proj4 from source
```bash
./configure SQLITE3_CFLAGS=-I/usr/local/include SQLITE3_LIBS=-lsqlite3 CPPFLAGS="-I/usr/local/include -fPIC" LDFLAGS="-L/usr/local/lib"
make -j4
sudo make install
```
Now system has two versions of Proj4 installed. One (old version) by yum, the other (most updated one) we just installed.
3. Install GDAL from source
```bash
./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib --with-proj=/usr/local
make -j4
sudo make install
```
Now system has two versions of GDAL installed. One (old version) by yum, the other (most updated one) we just installed.
4. Install GEOS from source
```bash
./configure
make -j4
sudo make install
```
5. Add a line `/usr/local/lib` to file `/etc/ld.so.conf.d/libgdal-x86_64.conf`.
Add a line `/usr/local/lib` to file `/etc/ld.so.conf.d/libgeos-x86_64.conf`.
Execute
```bash
sudo ldconfig
```
6. Now install `sf` package
```bash
sudo R -e 'Sys.setenv(PKG_CONFIG_PATH = "/usr/local/lib/pkgconfig/"); install.packages("sf", configure.args="--with-proj-include=/usr/local/include/ --with-proj-lib=/usr/local/lib/ --with-proj-share=/usr/local/share/proj/ --with-gdal-config=/usr/local/bin/gdal-config --with-geos-config=/usr/local/bin/geos-config")'
```
7. Install `tmap` package
```bash
sudo R -e 'install.packages(c("tmap", "gganimate"))'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment