[postgis-users] [!! SPAM] multipolygon to single polygon

Mehmet Erkek merkek at reidin.com
Fri Apr 27 01:41:24 PDT 2012


 

thanks Nicolas. Your point is fair. 

 

but in my specific case I found a easier way of doing it. in my  case all I need was to get the larger polygon which included other smallar polygons in its boundaries. 

 

I handled it with two queries below:

 

select f.id, collection ,st_area(collection) size into tmp from (select id, (st_dump(multipolygon)).geom as collection from "TempPolygons" )

as f order by id asc,size desc

 

select  tmp.id, collection into tmp3 from tmp 

right join 

(select id,max(size) as size from tmp group by id ) as  tmp2

on tmp.size=tmp2.size and tmp.id=tmp2.id

 

select * from tmp3; -> here is what I needed..

 

Thanks Nicolas, Julien for your quick support.

 

Regards

 

Mehmet Erkek

www.REIDIN.com <http://www.reidin.com/>  

 

 

From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Nicolas Ribot
Sent: 26 Nisan 2012 19:04
To: PostGIS Users Discussion
Subject: Re: [postgis-users] [!! SPAM] multipolygon to single polygon

 

This polygon cannot be represented as a single object, as it contains 2 separate polygons.

Only a MULTIPOLYGON can represent this object.

 

If you want to generate 2 objects from this polygon, re-dump the final union, and you will extract each individual part representing your coverage.

 

Nicolas

 

On 26 April 2012 17:57, Mehmet Erkek <merkek at reidin.com> wrote:

 

:) thanks Nicolas. 

 

Here is my data . it has two polygons in it. I want to convert this to one single polygon.. I have many raws like this. this is just an example. 

 

MULTIPOLYGON(((44.23219 37.044958,44.232267 37.044496,44.232391 37.043847,44.232478 37.043021,44.232565 37.042165,44.232692 37.04128,44.232701 37.040335,44.232281 37.03922,44.231698 37.038566,44.231192 37.03809,44.230647 37.037585,44.229867 37.037107,44.229007 37.036688,44.228148 37.036181,44.227327 37.035762,44.226585 37.035314,44.225252 37.034959,44.224662 37.035073,44.223167 37.035329,44.22234 37.035501,44.221435 37.035613,44.220767 37.035608,44.220257 37.035575,44.219985 37.035308,44.219949 37.034924,44.22023 37.034394,44.220824 37.033896,44.221616 37.033311,44.222367 37.032843,44.223552 37.032172,44.223988 37.031821,44.225014 37.031015,44.225607 37.030635,44.226243 37.029901,44.226839 37.029284,44.227997 37.027349,44.228435 37.02682,44.228793 37.02635,44.228837 37.025848,44.228843 37.025317,44.228808 37.024814,44.228589 37.023248,44.228838 37.021861,44.229077 37.021538,44.229633 37.020921,44.230188 37.020482,44.23082 37.020043,44.23173 37.019429,44.231851 37.019104,44.232053 37.018515,44.231979 37.018072,44.231513 37.017537,44.231085 37.01718,44.230658 37.016704,44.230505 37.01629,44.230509 37.015876,44.230867 37.015436,44.231421 37.015026,44.23221 37.014677,44.232958 37.014445,44.233632 37.013888,44.234427 37.01286,44.234828 37.012124,44.235617 37.011716,44.236522 37.011574,44.237897 37.011494,44.239662 37.011742,44.240329 37.011805,44.241114 37.01178,44.242294 37.01167,44.243317 37.01144,44.244028 37.01109,44.244266 37.010449,44.244509 37.009682,44.244714 37.008827,44.244995 37.008179,44.245766 37.005272,44.246167 37.004448,44.246804 37.003566,44.247163 37.002948,44.24875 37.001304,44.250062 36.999487,44.252713 37.00048,44.253684 37.000577,44.255382 37.000625,44.256983 36.999849,44.259312 36.999315,44.261689 36.999121,44.263969 36.999412,44.26688 36.999412,44.268918 36.999752,44.269597 36.999752,44.271441 36.999946,44.273333 37.000916,44.273867 37.002226,44.274643 37.002954,44.275662 37.003294,44.277215 37.002857,44.278379 37.002663,44.279932 37.003706,44.280514 37.004288,44.281873 37.006035,44.283522 37.006811,44.285997 37.007394,44.288083 37.008801,44.288617 37.010062,44.289199 37.010984,44.290654 37.011809,44.292449 37.013022,44.293759 37.013604,44.294584 37.014744,44.29473 37.015472,44.295409 37.016927,44.296622 37.018286,44.298078 37.018577,44.300261 37.018334,44.30225 37.01751,44.303123 37.016927,44.304627 37.016394,44.306326 37.016976,44.307975 37.017461,44.309528 37.017364,44.31011 37.018868,44.308363 37.020396,44.304725 37.023404,44.302105 37.025636,44.300892 37.026413,44.299873 37.027189,44.299436 37.028062,44.299436 37.02913,44.299776 37.030197,44.300892 37.030731,44.301959 37.030925,44.3039 37.030439,44.304773 37.030925,44.303366 37.032671,44.30094 37.036165,44.301668 37.037766,44.302529 37.041003,44.23219 37.044958)),((44.253299 36.985138,44.253097 36.984954,44.252473 36.984536,44.252044 36.984179,44.251695 36.983763,44.25162 36.983349,44.252098 36.982673,44.252691 36.982322,44.253557 36.982061,44.254041 36.981849,44.253299 36.985138)))

 

 

From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Nicolas Ribot
Sent: 26 Nisan 2012 18:37


To: PostGIS Users Discussion
Subject: Re: [postgis-users] [!! SPAM] multipolygon to single polygon

 

Sorry, I read too quickly.

I suggested what you tried ;)

 

what query are you running and what are your data to obtain multipolygons ?

 

Nicolas

 

On 26 April 2012 17:32, Nicolas Ribot <nicolas.ribot at gmail.com> wrote:

Hi,

 

As Julien suggested, you could st_dump to explode multipolygons into polygons, then union them.

It will produce a single polygon unioning all others:

 

with t as (

    select (st_dump(geom)).geom 

    from my_table

) select st_union(geom) from t;

 

Nicolas

 

On 26 April 2012 17:22, Mehmet Erkek <merkek at reidin.com> wrote:

Hi Juilen, thanks for quick answer. 

 

I have 1 geometry and 1 row on the table. this geometry is multiploygon which consists of 4 polygons.

I want to convert this mutlipolygon to one single polygon..

 

Any idea how I can do this?

I hope it is clearer now.

 

Thanks.

 

 

From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of ju
Sent: 26 Nisan 2012 18:02
To: PostGIS Users Discussion
Subject: Re: [postgis-users] [!! SPAM] multipolygon to single polygon

 

not clear...

1) if you have 4 polygons in 4 rows table distinct, this is not a multi object issu. for  this case use
 dissolve to group polygone into only one, this is not a topic of dump.


2) if you have 1 geometry and 1 row on the tablme, so this is a multi object topic
you must sperate the differents objet of the collection

here : http://www.postgis.org/docs/ST_GeometryN.html

--Extracting all geometries (useful when you want to assign an id)
SELECT gid, n, ST_GeometryN(the_geom, n)
FROM sometable CROSS JOIN generate_series(1,100) n
WHERE n <= ST_NumGeometries(the_geom);


best regards, julien



Le 26/04/2012 16:27, Mehmet Erkek a écrit : 

 

I have multipolygons which I would like to convert a single polygon. is there a way to do this? please check the attached image. I tried st_dump and afterwards st_union , but eventually I get a multipolygon again, not polygon. 

 

 

 

 

Mehmet Erkek

www.REIDIN.com <http://www.reidin.com/>  

 


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please Consider the Environment Before Printing This Email 

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

 

-- 
Julien-Pierre Guilloux
Service scientifique - Géomatique
Parc National des Ecrins
Domaine de Charance
05 000 GAP
tél : 04.92.40.20.10
fax : 04.92.52.38.34
julien.guilloux at ecrins-parcnational.fr


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please Consider the Environment Before Printing This Email 


_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

 

 


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please Consider the Environment Before Printing This Email 


_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120427/38c69036/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 11627 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120427/38c69036/attachment.png>


More information about the postgis-users mailing list