[gdal-dev] efficient querying of land and depth areas
Frank Warmerdam
warmerdam at pobox.com
Tue Oct 13 10:31:45 EDT 2009
Yilmaz Arslanoglu wrote:
> Hello everybody;
>
> I am using the OGR library to extract depth and land areas from
> an ENC file (S-57 format).
>
> What I want to do is to query whether a given point is on land
> or is on a depth area. For this purpose, I have to call OGRGeometry::Intersects
> or OGRGeometry::Contains functions for every polygon feature on one of
> these layers.
> (similarly, setting the point by SetSpatialFilter on one of these
> layers also does the job)
>
> I tried these and they work quite OK, but unfortunately quite
> inefficient at the same time.
> Is there anybody who can offer any tips or references about efficient querying?
Yilmaz,
If things devolve into GEOS tests for all polygons it is going to be very
slow. You might be able to make some progress with pretests against geometry
bounding rectangles which can avoid the conversion to GEOS format.
Generally speaking if the performance of this operation is important to you,
you should consider doing something fairly special. You might be able to use
GEOS at the C++ level and tie into methods to build it's internal spatial
indexing for a geometry set and then reuse it for subsequent point in polygon
tests.
Another approach would be to rasterize the land or sea polygons into a raster
of some appropriate density for the accuracy you want, and then use that to
test points.
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