[postgis-users] [?? Probable Spam] Re: multipolygon to single polygon
ju
julien.guilloux at ecrins-parcnational.fr
Thu Apr 26 08:51:56 PDT 2012
ok so this is second solution.
1) fisrt count the number of objet of the collection
select ST_NumGeometries(the_geom) as the_nb from YOURTABLE
you will obtain the number of collection, so probably 4 polygon
2) then "explose" theses 4 polygon :
SELECT
what you want....,
n,
ST_GeometryN(the_geom, n) as geom_unique,
ST_astext(ST_GeometryN(the_geom, n)) as geom_unique_txt
FROM YOURTABLE CROSS JOIN generate_series(1,100) n
WHERE n <= ST_NumGeometries(the_geom);
note : 100 is default for serie, if you count 4 objet in collection you
can write serie(1,4)
you shoud obtain 4 rows, the text format is juste here so as you see the
polygon coordinate
3) 2 choices
3.1 if one of the 4 polygon is what you want, then use it. for example
if it is the n number 3 then update your table with
update YOURTABLE set the_geom =
ST_GeometryN(the_geom, 3)
(dont forget a WHERE .... id of the row you want to update)
3.2) if you want to group all the 4 polygone to make a new one there are
other possibility
- for example make a table with the 4 polygons ( same query but "select
into table" .....)
with this table make a dissolve query to group the 4 objetc
- update your table with the result of dissolve
- you can also use array to group, etc...
tip : sometimes it is quick to copy /past result wkt of query
for example you copy the result wkt of the query for objet collection
number 3:
POLYGON((892426.5625 6463663,892432.9375 6463678,892434.4375
6463685,892454.75 6463802,892457.0625 6463879.5,892456.6875
6463879.5,892453.6875 6463931,892453 6463931))
then you make a polygon with it :
update matable set the_geom = ST_GeometryFromText('POLYGON((892426.5625 6463663,892432.9375 6463678,892434.4375
6463685,892454.75 6463802,892457.0625 6463879.5,892456.6875
6463879.5,892453.6875 6463931,892453 6463931))'
(dont forget a WHERE .... id of the row you want to update)
Le 26/04/2012 17:22, Mehmet Erkek a écrit :
>
> 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 <mailto: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 <mailto: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
--
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120426/e0632fae/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 11627 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120426/e0632fae/attachment.png>
More information about the postgis-users
mailing list