Skip to content
Prev 17040 / 29559 Next

reading PostGIS table into sp data frame

Sorry, me again.

The PostGIS driver might be missing from the pre-compiled version of rgdal for Windows, but the ODBC driver isn't; so that should be an alternative to using a driver specific for PostGIS. But as already mentioned, the following R statement
results in the following output:

Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding) : 
  Multiple # dimensions:

I checked the log files of the postgresql server; there seems to be an sql statement asking for a non-existing field:

192.168.56.101(49436): evberghe: 2012-12-22 12:27:00 EST: LOG:  connection authorized: user=evberghe database=obis	
192.168.56.101(49436): evberghe: 2012-12-22 12:27:00 EST: ERROR:  column "geometry_type" does not exist at character 41	
192.168.56.101(49436): evberghe: 2012-12-22 12:27:00 EST: STATEMENT:  SELECT f_table_name, f_geometry_column, geometry_type FROM geometry_columns	
	

I assume rgdal is checking whether all records have the same number of dimensions and the same geometry type. The geometry type is in a field 'type', not in a field 'geometry_type'.

Is it because the PostGIS driver is not available that the ODBC driver doesn't know the correct field in which to look for the geometry type? 

I could ask the PostgreSQL server to log everything and post the relevant sections of the log if this would help.

Edward

-----Original Message-----
From: Roger Bivand [mailto:Roger.Bivand at nhh.no] 
Sent: 21 December 2012 13:31
To: Edward Vanden Berghe
Cc: r-sig-geo at r-project.org
Subject: RE: [R-sig-Geo] reading PostGIS table into sp data frame
On Fri, 21 Dec 2012, Edward Vanden Berghe wrote:

            
Not out of luck, the users of the CRAN Windows and OSX rgdal binaries are very lucky indeed, thanks to hard work by Uwe Ligges, Brian Ripley and Simon Urbanek. At least many of the most commonly used drivers are present.

There never is a complete set of drivers ionstalled in any GDAL, some depend on proprietary dynamically linked objects.

file.show(system.file("README.windows", package="rgdal"))

displays the accumulated - but *not* updated - wisdom with regard to installing source rgdal on Windows, linked to an external GDAL DLL. If you try to follow this route, please pass back your experience with regard to installing - it is likely that much has changed. You may find that OSGeo4W is another source for a Win32 GDAL binary, but I don't see from the documentation whether it supports PostGIS.

Installing Linux, PostgreSQL, PostGIS, GDAL, Proj.4, etc., then R and rgdal under Linux will probably require less jumping through hoops than building rgdal against an external 64-bit GDAL under windows.

Hope this helps,

Roger
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics, 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