[gdal-dev] OGR_L_SetSpatialFilter

Even Rouault even.rouault at spatialys.com
Fri Sep 22 14:45:10 PDT 2017


On vendredi 22 septembre 2017 16:54:00 CEST Andrew Bell wrote:
> Hi,
> 
> Is there any reason to use OGR_L_SetSpatialFilter if you're fetching a
> layer using OGR_DS_Execute_SQL?  Am I missing something or can I place
> whatever filter (via a where clause) on the SQL statement that I might
> otherwise use in a call to OGR_L_SetSpatialFilter?
> 

(There would be even as third option, pass the spatial filter object as third argument of 
OGR_DS_Execute_SQL(), which in general should do the same as calling 
OGR_L_SetSpatialFilter() afterwards.)

The reason for those dedicated way of expressing a spatial filter is that not all OGR drivers 
support expressing a spatial filter as a SQL statement. In fact only the drivers that connect to 
engines with spatial capabilites can (PostGIS, Oracle, etc..) and for which OGR passes directly 
the SQL statement, but shapefiles, mapinfo files etc cannot. So you're absolutely free to 
enclose a spatial filter in the SQL itself when the underlying database support it. This will 
even allow you to do spatial filtering for complex queries (with joins, etc) where adding it as a 
post filter would be less efficient.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170922/89d00d2c/attachment.html>


More information about the gdal-dev mailing list