rgdal library not loading

Hi all, I'm having trouble loading the rgdal library. I have updated R and RStudio. I'm on a MacBook and recently updated to OS 11.0.1. Below are the error messages. Any help greatly appreciated. Thank you!


trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/rgdal_1.5-18.tgz'
Content type 'application/x-gzip' length 83963272 bytes (80.1 MB)

downloaded 80.1 MB

The downloaded binary packages are in

Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so, 6): Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so
Reason: image not found

rgdal library for R relies on your system having GDAL utility, so you'll have to research how to install GDAL for macos, before attempting to install the R package that depends on it.

Same issue here. Unable to load rgdal or sf after "upgrade" to Big Sur. I reinstalled GDAL, but that didn't work. Any tips greatly appreciated!!

Welcome @sedano. It looks like you're missing the libpq dependency, which can be found on homebrew. First, just try going through steps 1 to 3, and see if that works. If not, you can always recompile rgdaland sf to point to homebrew's libraries.

Step 1. Instructions for installing homebrew can be found at: https://brew.sh/

Step 2. Make sure you have the xcode command line tools installed. In a terminal, type
xcode-select --install

Step 3. In a terminal, type
brew install libpq gdal proj geos

to install the dependencies for Mac OS X.

Step 4. In R, set configure options to point to the homebrew dependencies

install.packages('rgeos', type = 'source', configure.args = "--with-geos-config=/usr/local/opt/geos/bin/geos-config")
install.packages("rgdal",  configure.args = '--with-gdal-config=/usr/local/opt/gdal/bin/gdal-config --with-proj-include=/usr/local/opt/proj/include --with-proj-lib=/usr/local/opt/proj/lib --with-proj-share=/usr/local/opt/proj/share/proj', type = 'source')


install.packages("sf", configure.args = "--with-gdal-config=/usr/local/opt/gdal/bin/gdal-config --with-proj-include=/usr/local/opt/proj/include --with-proj-lib=/usr/local/opt/proj/lib --with-proj-share=/usr/local/opt/proj/share/proj", type = 'source')