[postgis-users] Intersection of three polygons

Giuseppe Broccolo giuseppe.broccolo at 2ndquadrant.it
Wed Feb 22 01:06:05 PST 2017


Hi Saranya,

2017-02-21 10:51 GMT+01:00 Saranya Kuniyil <saranyak578 at gmail.com>:

> Hai,
> yes. I am interested to retrieve all polygons which intersects any one
> among three categories..
> In the above example,
> 1)POLYGON((0 0,0 1,1 1,1 0,0 0))   filename as part1
> POLYGON((0 0,0 2,2 2,2 0,0 0))   filename as part2
> POLYGON((0 0,0 3,3 3,3 0,0 0))   filename as part3
> From these polygons I need to get Intersecting polygon as POLYGON((0 0,0
> 1,1 1,1 0,0 0)),
>
> 2)POLYGON((0 0,0 3,3 3,3 0,0 0))   filename as part1
> POLYGON((0 0,0 2,2 2,2 0,0 0))   filename as part2
> POLYGON((0 0,0 3,3 3,3 0,0 0))   filename as part3
> From these polygons I need to get Intersecting polygon as POLYGON((0 0,0
> 2,2 2,2 0,0 0)).
>
> 3)POLYGON((0 0,0 3,3 3,3 0,0 0))   filename as part1
> POLYGON((0 0,0 5,5 5,5 0,0 0))   filename as part2
> POLYGON((0 0,0 4,4 4,4 0,0 0))   filename as part3
> From these polygons I need to get Intersecting polygon as POLYGON((0 0,0
> 3,3 3,3 0,0 0)).
> Other combinations also returns same answer.
>

So, it could be possible that some intersecting geometries (properly
referred to different categories) are
actually one contained into the other, and so on. You could benefit of the
technique reported in this interesting
article::

http://postgis.net/2014/03/14/tip_intersection_faster/

to speed up the intersection computation (that is quite expensive in time).
I'm asking this because I see you were
filtering on overlapping (not just intersecting) geometries through the
condition on ST_Overlaps. This one is more
restrictive than the ST_Intersects one, so consider to use one or the other
basing on what you really need to filter.

Hope this can help.

Giuseppe.

-- 
Giuseppe Broccolo - 2ndQuadrant Italy
PostgreSQL & PostGIS Training, Services and Support
giuseppe.broccolo at 2ndQuadrant.it | www.2ndQuadrant.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20170222/aad835a5/attachment.html>


More information about the postgis-users mailing list