[Gdal-dev] spatial intersection of ogr geometry and shapefile features

Martel, Christian Christian.Martel at drdc-rddc.gc.ca
Wed Jun 6 14:39:23 EDT 2007


Frank,

With FWTools 1.1.3 I do not have GEOS support. It's not an issue because
SetSpatialFilter give a bbox comparison (I verified it). If I want an
intersection with the feature geometry instead of the bbox, I just need
to add an Intersection test. Otherwise, if I always want a bbox
comparison (even with future version of FWTools with GEOS support), I
will create a shp with bbox of countries.
Thanks for you help,
Christian

-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: 6 juin 2007 15:25
To: Martel, Christian
Cc: gdal-dev at lists.maptools.org
Subject: Re: [Gdal-dev] spatial intersection of ogr geometry and
shapefile features

Martel, Christian wrote:
> Frank,
> 
> Thanks. This is the hint I was looking for.
> 
> I read in the doc about SetSpatialFilter:
> "Currently this test is may be inaccurately implemented, but it is 
> guaranteed that all features who's envelope (as returned by
> OGRGeometry::getEnvelope()) overlaps the envelope of the spatial 
> filter will be returned. This can result in more shapes being returned

> that should strictly be the case."
> 
> It's ok because I only want a bbox comparison. Do you plan to update 
> the function to do an intersection test with the actual geometry ? If 
> so I should try something else to ensure my code will always return 
> the same result.

Christian,

In fact, right now if you build with GEOS support enabled for OGR and
you use a non-rectangular geometry with SetSpatialFilter() I believe it
does an exact test for most drivers.  Some drivers (such as RDBMS
drivers) implement the spatial test themselves and may only use bounding
boxes.

If you very specifically only want a bounding box comparison, then you
should use a rectangular envelope for your target region, rather than an
irregular shape.

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