[gdal-dev] OGR Select Features by Location...

Frank Warmerdam warmerdam at pobox.com
Wed Jan 23 14:34:45 EST 2008


Roger André wrote:
> Hmm, performance is a good point.  I thought that SetSpatialFilter only 
> returned the intersection of the 2 envelopes though?  Will that 
> accurately capture only points that are within an odd-shaped polygon.

Roger,

If you build GDAL with GEOS support, and your spatial filter is not
rectangular, OGR will actually do an initial comparison based on
envelopes, but then do a refined test based on proper intersection
of the spatial filter polygon with the feature geometry.

However, this is a fairly expensive operation and I still sort of wonder
How badly you need this sort of operation.  Doing a spatial filtering with
a complex polygon against a *lot* of points will be slow.

I don't recall the details of your original email, but I can't help but
wonder if some post spatial filtering (based on rectangular filters)
examination in your own code might not be more appropriate.

One warning ... I believe GEOS builds some sort of a spatial index for
a polygon for doing intersect operations. But because of the way things
are organized in OGR, GEOS will have to rebuild this spatial index for
every single geometry compared against it.  Not effort is made to preserve
this work.  In fact, I don't even believe this is currently possible through
the GEOS C API though I could be confused.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list