[postgis-users] polygons inside polygon
Marcin Mionskowski
mionskowskimarcin at gmail.com
Mon Nov 29 23:39:55 PST 2021
Assuming (1) your problem is not trivial (you have more then one "outer
most" polygon) and (2) there can be only one type of spatial relationship
(polygons are properly contained
https://postgis.net/docs/ST_ContainsProperly.html) below is my take on this:
select distinct on (t1.id) t1.id,t2.id
from t t1,t t2
where ST_Area(t1.geom)>ST_Area(t2.geom)
and ST_Intersects(t1.geom,t2.geom)
order by t1.id,ST_Area(t2.geom) desc;
Enclose this in CTE and then just select "outer" polygons based on left
column and "inner" based on right column.
wt., 30 lis 2021 o 07:30 <paul.malm at lfv.se> napisał(a):
>
>
>
>
> Hi,
>
> I have a polygon layer where polygons are inside other polygons (could be
> polygons in polygons in polygons…).
>
> I would like to separate them in 2 different layers, one layer with the
> outer most polygon and one layer with all polygons that has a surrounding
> polygon.
>
> Is there a smart way to do this in SQL?
>
>
>
> Thanks,
>
> Paul
>
> [image: 1_LFV_svensk_96]
>
> Paul Malm
>
>
>
> Operations / AIM Flyginfo SE
>
>
>
> Direkt 08-797 70 23 Mobil 070-860 11 15
> paul.malm at lfv.se
>
> Besöks- och postadress
> LFV Flyginfo SE
>
> Af Pontins väg 6
>
> 115 21 STOCKHOLM
>
>
>
>
>
>
>
> Tänk på miljön innan du skriver ut detta e-postmeddelande.
>
>
>
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20211130/3b7a3b27/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 3211 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20211130/3b7a3b27/attachment.jpg>
More information about the postgis-users
mailing list