Search code examples
rpostgresqlpostgisgdalrgdal

Mac postgres/postgis driver for rgdal


I'm trying to get rgdal to read polygon data directly from a postgis-enabled database, but things aren't working too smoothly. I'm using OSX 10.9.2 with R 3.0.2 and I have the complete GDAL 1.10.1 framework installed from Kyngchaos. Specificlly this: http://www.gdal.org/ogr/drv_pg.html is the driver I want. I've confirmed that /Library/Frameworks/GDAL.framework/Versions/Current/Libraries/libpq.dylib exists - as I currently understand it this is the driver I need.

The rgdal package is compiled from source against the installed gdal framework using:

sudo R CMD install rgdal_0.8-16.tar.gz --configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/unix/bin/gdal-config --with-proj-include=/Library/Frameworks/PROJ.framework/unix/include --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'

which completes successfully. There's no issue loading rgdal, but the postgres driver refuses to appear:

> ogrDrivers()
             name write
1      AeronavFAA FALSE
2          ARCGEN FALSE
3          AVCBin FALSE
4          AVCE00 FALSE
5             BNA  TRUE
6         CouchDB  TRUE
7             CSV  TRUE
8             DGN  TRUE
9             DXF  TRUE
10         EDIGEO FALSE
11  ElasticSearch  TRUE
12 ESRI Shapefile  TRUE
13     Geoconcept  TRUE
14        GeoJSON  TRUE
15         GeoRSS  TRUE
16            GFT  TRUE
17            GML  TRUE
18            GMT  TRUE
19       GPSBabel  TRUE
20  GPSTrackMaker  TRUE
21            GPX  TRUE
22            HTF FALSE
23         Idrisi FALSE
24            KML  TRUE
25   MapInfo File  TRUE
26         Memory  TRUE
27            ODS  TRUE
28        OpenAir FALSE
29            OSM FALSE
30         PCIDSK  TRUE
31            PDF  TRUE
32            PDS FALSE
33         PGDump  TRUE
34            REC FALSE
35            S57  TRUE
36           SDTS FALSE
37       SEGUKOOA FALSE
38           SEGY FALSE
39         SQLite  TRUE
40            SUA FALSE
41            SVG FALSE
42          TIGER  TRUE
43        UK .NTF FALSE
44            VFK FALSE
45            VRT FALSE
46            WFS FALSE
47            XLS FALSE
48           XLSX  TRUE
49         XPlane FALSE

Am I missing something obvious?

(EDIT: Note that ogrinfo "PG:[conneciton string here]" works perfectly, so the driver is certainly working)


Solution

  • Sorry for the self answer, but I've solved it.

    Forget the rgdal package you get from the CRAN repos, it includes its own basic gdal which doesn't have the necessary driver. I still don't understand why compiling from source didn't work, but regardless you can get a copy of rgdal which does work from:

    http://www.kyngchaos.com/software/frameworks