[R-sig-Geo] RE : rgdal problem when connecting with postgres
Cédric Briand
cedric.briand at lavilaine.com
Sun Jan 31 22:27:31 CET 2010
Dear Roger
Thank you for your answer.
I have done the following :
-----------------------------------------
Run in OSGeo4W console, after setting:
set OSGEO4W_BUILD=yes
set GDAL_HOME=%OSGEO4W_ROOT%
download rgdal sources
cd C:/rgdal/src
using visuel c++ (vc9) command line
cl /MT /Ox /EHsc /D "WIN32" /c /I "C:/Program Files/R/R-2.10.1/include" /I C:/OSGeo4W/include /I "C:\Program Files\Microsoft Visual Studio 9.0\VC\include" /D OSGEO4W *.cpp
-------------------------------------------------------
at this point, following your insctructions, I need a rdll.lib, and was not able to produce it ...
I understand I have to download the source and try the following code, but it fails.
C:\R-2.10.1\src\gnuwin32>make R.exp
-------------------------------------------------
gcc -std=gnu99 -I../include -I. -I../extra -DHAVE_CONFIG_H -DR_DLL_BUILD -O3 -W
all -pedantic -c console.c -o console.o
console.c:23:20: error: config.h: No such file or directory
console.c:73: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Ch
aracterMode'
console.c: In function 'console_normalkeyin':
console.c:1357: error: 'CharacterMode' undeclared (first use in this function)
console.c:1357: error: (Each undeclared identifier is reported only once
console.c:1357: error: for each function it appears in.)
console.c:1357: error: 'RGui' undeclared (first use in this function)
make: *** [console.o] Error 1
---------------------------------------------------
Cédric
________________________________________
De : Roger Bivand [Roger.Bivand at nhh.no]
Date d'envoi : vendredi 29 janvier 2010 20:11
À : Cédric Briand
Cc : r-sig-geo at stat.math.ethz.ch
Objet : Re: [R-sig-Geo] rgdal problem when connecting with postgres
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