[Gdal-dev] Using SetSpatialFilter() on MapInfo .tab files
Frank Warmerdam
warmerdam at pobox.com
Wed Nov 8 10:58:12 EST 2006
Mir Hassan Ali wrote:
> layer.SetSpatialFilter(
>
> new Geometry(ogr.wkbUnknown , "POINT(393544.0 377079.0)", 0, null , null));
> But after settign the filter I get feature count = 0 whereas it should
> be 2 for the particular point.
> I am getting this pair of coordinates from a LLPG(Local land and
> property gazetteer). Do I need to transform these coordinates in some
> way before setting the filter or is there something else I am doing wrong?
> Please will someone guide me regarding this problem.
Mir,
I think Tamas has already addressed some particulars of how to create the
geometry. I just wanted to mention that:
o SetSpatialFilter geometries need to be in the same coordinate system as
the layer to work properly. Internally OGR does not checking on this,
and will just assume they match. So as long as the above coordinates
match the coordinate system of the layer (compare to the layer geometries
with ogrinfo) you should be ok.
o Most of the time OGR just uses an MBR of the geometry you give it for
spatial filtering purposes, but when GEOS is enabled it will also do
an extra intersection test with geometries that are not obvious
rectangles (simple five vertex closed polygons). So you using
non-rectangular polygons as the filter can result in quite a bit of extra
computation expense in some scenarios. I see that SetSpatialFilterRect()
is exposed in C#, and so you should use that most of the time. For a point
just set the minx=maxx=x, miny=maxy=y.
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