This issue has been discussed few times and any of the read posts have not been the ultimate answer for my case:

I'm trying to load data from a PostGIS database into the R Console. While many packages in R are suitable for it, it seems to be that only rgdal is able to implement directly spatial capabilities.

The bad new is (as mentioned in many posts) the installation of rgdal from CRAN in windows does not include the driver PostgreSQL (the driver is not listed by the command ogrDrivers() in the R Console).

I loaded the source for rgdal from the CRAN site to build the package myself as recommended in some posts but I always get an error message:

OGR_write.cpp:1:24: fatal error: cpl_string.h: No such file or directory

The same error appears when trying to install the package from GitHub:


Is there a way or a guide (for dummies) that can help me getting the PostgreSQL driver enabled in rgdal?

Further information that may be required to answer this question:

  • My operative System: Windows 7 64-bit
  • R-3.3.3 installed at C:\Program Files\R\R-3.3.3
  • GDAL-2.0.1 installed at C:\Program Files\GDAL
  • FWTools-2.2.8 installed at C:\Program Files (x86)\FWTools2.2.8
  • Rtools-34 installed at C:\Rtools
  • try using osgeo4w instead of the now unsupported fwtools trac.osgeo.org/osgeo4w
    – Ian Turton
    Apr 11, 2017 at 15:01
  • Yes, I forgot to mention it, I have both OSGeo4W and OSGeo4W64 installed direct on C:\. I just don't know how to build rgdal including the PostgreSQL driver in Windows...
    – Migue Lo
    Apr 12, 2017 at 6:27


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.