[Gdal-dev] using OGRLayer::SetSpatialFilter to access polygons in .shp files

Frank Warmerdam warmerdam at pobox.com
Sat Jun 17 23:06:12 EDT 2006


Amanda Tucker wrote:
> Hello,
> 
>  
> 
> My goal is to input a point (lat/long) and to get all polygons that 
> contain this point.  I am using SetSpatialFilter() to filter on the 
> specified point.  I am being returned correct features (polygons), but 
> often, I am getting extra polygons.  I can see through GUI tools that 
> some polygons/multipolygons are being returned that do not contain the 
> point.  The doc for SetSpatialFilter() states ‘currently this test may 
> be inaccurately implemented’.  Are there known cases that this method is 
> inaccurate?  And is this one of those cases?  Is there another way to 
> get the results I desire?  I also tried using within()/contain() after 
> these polygons were returned, but that did not work because I am not 
> building with GEOS.  Is there any way I can get the correct results 
> without building with GEOS?  And if not, where do I find the GEOS 
> binaries/source code to build with OGR?  And will these methods in GEOS 
> even solve my problem?

Amanda,

I believe the test is always passed on comparing the feature geometries
bounding rectangle to the spatial filter's bounding rectangle unless
GEOS support is built in, in which case I think a real intersection test
is done.

I believe FWTools is always built with GEOS if you want to use that for
a quick trial.  http://fwtools.maptools.org/

GEOS can be found at http://geos.refractions.net/

I see there is a PointOnSurface() method on the OGRPolygon that is not
yet implemented.  I likely ought to wire that to something when GEOS is
available.  In fact, point in polygon is not a very hard test for me to
do with using GEOS.

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 OSGF, http://osgeo.org




More information about the Gdal-dev mailing list