[Gdal-dev] OGR - Features Selection from Point or MultiPoint

Frank Warmerdam warmerdam at pobox.com
Wed Nov 2 11:00:00 EST 2005


On 11/1/05, Mateusz Łoskot <mateusz at loskot.net> wrote:
> Hi,
>
> AFAIK the only way to do spacial selection of features
> is to define filter and pass it to the OGRLayer::SetSpatialFilter.
> This is clear.
> I wonder if is this possible to select features passing OGRPoint or
> OGRMultiPoint to the OGRLayer::SetSpatialFilter?
>
> My aim is to be able to select i.e 1 polygin (passing OGRPoint) or >1
> polygons in relation: disjoint and not touched - completely separated
> (here comes OGRMultiPoligon as filter).
>
> My second question is: is there any way to modify spatial filter after
> it is defined?
> What I'd like to achive is to select one feature (first SetSpatialFilter
> call) and after that select another featuer (second SetSpatialFilter
> call) then I have two features selected. Is this possible?

Mateusz,

If GDAL/OGR is built with GEOS support, then
non-rectangular spatial filters will be tested against
read geometries using the GEOS Intersect operation.
So if you passed a multipoint, then any geometries
intersected by any of those points would be returned.

If you don't have GEOS built in, a bounding box for the
spatial filter will be derived, and any intersection with that
bounding box will be considered a positive hit.

You can modify the spatial filter by calling SetSpatialFilter()
again, but keep in mind this implicitly calls ResetReading().

There is no way to use SetSpatialFilter to do tests other
than Intersect().   If you need that you are better off to
use the spatial filtering to grossly filter the features, and
then perform exact tests with the appropriate methods after
reading the features.

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