Skip to content

passing SQL through readOGR()

3 messages · Tom Gottfried, Barry Rowlingson, Roger Bivand

#
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
#
On Tue, Oct 13, 2009 at 4:34 PM, Tom Gottfried <tom.gottfried at wzw.tum.de> wrote:
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:

            
No, not implemented. Please use ogr2ogr externally for this, implementing 
it internally would be duplicating code.

Roger