Using the latest GDAL with R packages on macOS - redux

Jan 8, 2020 · 1 min read
posts

As an update to an earlier post, here’s how to use the latest versions of GDAL/PROJ with R spatial packages.

Install GDAL

brew install pkg-config
brew install gdal

(Re)install R spatial packages

Next, we need to install a few packages from source in order to use the new GDAL libraries:

## (re)install spatial packages from source
install.packages(c("rgeos", "sf", "sp"), type = "source")

## rgdal requires some additional configuration to build correctly:
##   based on http://stackoverflow.com/a/26836125/1380598
install.packages("rgdal", type = "source",
                 configure.args = c("--with-proj-include=/usr/local/include",
                                    "--with-proj-lib=/usr/local/lib"))
library(rgdal) ## confirm the GDAL version being used
Alex M Chubaty
Authors
Ecologist and simulation modeller

Dr. Chubaty is an ecologist and simulation modeller who builds spatial models of forest landscapes and the species that live in them. He completed his PhD at Simon Fraser University modelling host selection in mountain pine beetle (MPB), followed by postdoctoral research at Université Laval and Natural Resources Canada developing forecasting models of MPB spread.

He runs FOR-CAST Research & Analytics in Calgary, Canada. His recent work includes LANDIS-II forest landscape simulation studies, landscape connectivity modelling, and analyses of insect outbreak dynamics, to inform land management and species-at-risk decisions. He writes open-source R packages for this work, including grainscape for connectivity analysis, landisutils for LANDIS-II simulations, and co-developed the SpaDES simulation platform. He advocates for open data and reproducible workflows.