Hi list, is there a way to pass any SQL-statement through readOGR (as with the -sql Option to ogr2ogr). I want to import a subset of a large dataset from PostGIS into R. I know it's possible with for example RODBC and then coercing the resulting data.frame to an sp-class, but I wonder if I can do it directly through readOGR(). Thanks! Tom
passing SQL through readOGR()
3 messages · Tom Gottfried, Barry Rowlingson, Roger Bivand
On Tue, Oct 13, 2009 at 4:34 PM, Tom Gottfried <tom.gottfried at wzw.tum.de> wrote:
Hi list, is there a way to pass any SQL-statement through readOGR (as with the -sql Option to ogr2ogr). I want to import a subset of a large dataset from PostGIS into R. I know it's possible with for example RODBC and then coercing the resulting data.frame to an sp-class, but I wonder if I can do it directly through readOGR().
If you cant get the sql into readOGR directly (and I anticipate a post from Roger telling you how to do that to appear about three seconds after I hit 'send') then you might be able to do it with the OGR virtual driver: http://www.gdal.org/ogr/drv_vrt.html There's an example there with some SQL embedded in the XML. Barry 3...2...1....
On Tue, 13 Oct 2009, Tom Gottfried wrote:
Hi list, is there a way to pass any SQL-statement through readOGR (as with the -sql Option to ogr2ogr). I want to import a subset of a large dataset from PostGIS into R. I know it's possible with for example RODBC and then coercing the resulting data.frame to an sp-class, but I wonder if I can do it directly through readOGR().
No, not implemented. Please use ogr2ogr externally for this, implementing it internally would be duplicating code. Roger
Thanks! Tom
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
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