Dear list members
We are using R 2.10.1 and rgdal Version: 0.6-20, and are working with windows XP
Following the nice example found at http://wiki.intamap.org/index.php/PostGIS<http://wiki.intamap.org/index.php/PostGIS> we tried to connect to our postgres database

library(rgdal)
trial = readOGR("PG:dbname=CCM", "riversegments")


This does not work. We have tried to use ogr2ogr and examples found at

http://www.bostongis.com/?content_name=ogr_cheatsheet

and they work fine particularly we were able to connect to our database using the following script


C:\OSGeo4W\bin\ogr2ogr -f "ESRI Shapefile" C:\base\basesig\essai.shp PG:"host=localhost user=postgres dbname=CCM password=postgres port=5433" "riversegments





As this works we translated the more complex dsn into the rgdal command line



require(rgdal)

readOGR(dsn="PG:host=locahost user=postgres dbname=CCM password=postgres port=5433",layer="riversegments")



but it always returns a "Cannot open file" error :



> require(rgdal)

Le chargement a nécessité le package : rgdal

Le chargement a nécessité le package : sp

Geospatial Data Abstraction Library extensions to R successfully loaded

Loaded GDAL runtime: GDAL 1.6.2, released 2009/07/31

Path to GDAL shared files: C:/Program Files/R/R-2.10.0/library/rgdal/gdal

Loaded PROJ.4 runtime: Rel. 4.6.1, 21 August 2008

Path to PROJ.4 shared files: C:/Program Files/R/R-2.10.0/library/rgdal/proj

> readOGR(dsn="PG:host=localhost dbname=CCM user=postgres passwd=postgres port=5433",layer="riversegments")

Erreur dans ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding = input_field_name_encoding) :   Cannot open file


The ogrInfo in command line found at 'C:\OSGeo4W\bin\ogrInfo.exe' does seem to work (it does not return any error)



The reason behind this failure seems to be that PostgresSQL is not listed in the drivers availaible with the package.

> ogrDrivers()

             name write

1          AVCBin FALSE

2          AVCE00 FALSE

3             BNA  TRUE

4             CSV  TRUE

5             DGN  TRUE

6  ESRI Shapefile  TRUE

7      Geoconcept  TRUE

8         GeoJSON  TRUE

9             GML  TRUE

10            GMT  TRUE

11            GPX  TRUE

12            KML  TRUE

13   MapInfo File  TRUE

14         Memory  TRUE

15            REC FALSE

16            S57  TRUE

17           SDTS FALSE

18          TIGER  TRUE

19        UK .NTF FALSE

20            VRT FALSE

21         XPlane FALSE



After many trials we are at a loss on how to add a driver to the drivers in R. So any hint would be really valuable.



Cédric




	[[alternative HTML version deleted]]

