[gdal-dev] Python Buffer Features

Frank Warmerdam warmerdam at pobox.com
Mon Mar 1 11:36:33 EST 2010


Spencer Gardner wrote:
> I'm writing some code that involves buffering a feature in a point layer and
> then doing a spatial filter with another set of layers.  I've got everything
> working just fine but I'm having a hard time determining how the spatial
> filter works.  Based on the documentation, it looks like all features that
> intersect the buffer will be included.  Is this true?  Is there any way to
> include only those features which are completely within the buffer?

Spencer,

The actual behavior may depend on whether you have built with GEOS support
or not.  Without it, you are guaranteed to get back all features which
intersect the spatial filter geometry but there may be extras.  In fact,
in this situation the comparison is strictly done as a bounding box to
bounding box comparison.

If GDAL is built with GEOS support, then a final "real" intersect test is
done using GEOS.

Currently there is no way to request the spatial filter to return only
geometries that are entirely within the spatial filter region.  So you
would need to do an extra test on the features you get to determine if
they fall entirely within the filter geometry.  I believe the
OGRGeometry::Within() test is appropriate for this.

> On a related note, how do I know what the units of the spatial filter are?
> Does it simply use the units of the original shapefile?  Is there any way to
> use different units?

The spatial filter is interpreted as being in the same coordinate system
as the layer it is being used with.  If you are working with a shapefile
then this will be the coordinate system of the shapefile.

There is no provision for comparing or filtering with different units
than the underlying layer.

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    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list