[postgis-users] Finding if a polygons is fully covered by others

Nicklas Avén nicklas.aven at jordogskog.no
Mon Jan 18 01:39:17 PST 2010


Hallo  look at  ST_CoveredBy, ST_Covered, ST_Contain and ST_ContainProperlyin dochttp://www.postgis.org/documentation/manual-1.4/
They all handle this questions in slightly different ways.I think all of them will use any potential index, but look in doc to be sure.  Hope that helpsNicklas 
2010-01-18 Nicolas Gillet - MARKET-IP wrote:

>
Hello,
 
 
 
I am looking for some help in optimizing a query.
 
 
 
I have a table with bounding boxes and sometimes I need to find if a new given polygon can be fully covered by existing bounding boxes of my table.
 
 
 
Right now I can find it out by summing the areas of intersections between my polygon and those in my table and comparing this computed area with my polygon area.
 
 
 
Heres the query :
 
 
 
SELECT ST_area(ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 0))', 4326) ) -
 
(SELECT SUM(st_area(st_intersection(the_geom, ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 0))', 4326) ) ))
 
                FROM tests WHERE the_geom && ST_GeometryFromText('POLYGON((-1 0, -1 1, 1 1, 1 0, -1 0))', 4326) )
 
 
 
=> if query returns 0 then my polygon can be fully covered if != 0 then it cant.
 
 
 
But I was wondering if there couldnt be an easier way to do this.
 
 
 
Thank you.
 
 
 
Nicolas.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100118/a96db2a1/attachment.html>


More information about the postgis-users mailing list