Install sf for r using gdal from postgresapp

332 views Asked by At

I am on MacOSX 11.4 Big Sur.

I have just installed on my computer https://postgresapp.com, which bundles PostgreSQL together with the needed libraries for PostGIS (proj, geos, and gdal).

I am able to use command line functions like ogr2ogr, gdalinfo etc. from my terminal, indicating that gdal is successfully installed.

I now want to install the "sf" package for R version 4.1.0. I am able to successfully install "sf", but the PostgreSQL driver is missing when I use the native installation

install.packages("sf")

According to the sf documentation and things I have read elsewhere on stack, this is a known issue for MacOSx, and the recommended workaround for this problem is to separately install gdal using homebrew or the kyngchaos binaries. However, I would like to use the gdal installation used by the postgresapp binary mentioned earlier so that there is only one installation on my computer..

According to the postgresapp installation documentation (https://postgresapp.com/documentation/install.html), the relevant paths are:

Binaries: /Applications/Postgres.app/Contents/Versions/latest/bin

Headers: /Applications/Postgres.app/Contents/Versions/latest/include

Libraries: /Applications/Postgres.app/Contents/Versions/latest/lib

Therefore, when combined with the "sf" documentation my assumption is that the following should work.

install.packages("sf", configure.args = "--with-gdal-lib=/Applications/Postgres.app/Contents/Versions/latest/lib/"

Although I receive no errors or warnings, this does not fix the problem for me as sf::st_drivers() still does not list the PostgreSQL driver as an option. Can someone please help me figure out what additional configuration arguments, if any, are needed to get sf to recognise the Postgres driver?

0

There are 0 answers