[R-sig-Geo] rgdal problem when connecting with postgres
Roger Bivand
Roger.Bivand at nhh.no
Fri Jan 29 20:11:19 CET 2010
On Fri, 29 Jan 2010, Cédric Briand wrote:
> Dear list members
> We are using R 2.10.1 and rgdal Version: 0.6-20, and are working with
> windows XP.
If you mean the Windows binary rgdal package, then the answer is in
file.show(system.file("README", package="rgdal"))
file.show(system.file("README.windows", package="rgdal"))
The Windows binary package builds the minimal set of drivers, with only
one external dependency (expat for reading GPX and KML). The file refered
to describes how you might build rgdal from source, using FWTools or
OSGEO4W as the provider of GDAL and its dependent DLLs. If you do try this
out (look for the chunk beginning: "Initial notes for OSGeo4W"), and if:
source(system.file("OSGeo4W_test", package="rgdal"), echo=TRUE)
works, as well as PostGIS access, please let me know.
Roger
> 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
>
PS. That example was run on Linux with GDAL built with PostGIS, and rgdal
installed as a source package.
> 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]]
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list