[postgis-users] create multipolygon

eehab hamzeh eehab40 at hotmail.com
Thu Sep 24 05:48:41 PDT 2009


Dear Maxime 

Thanks for your replay, i checked the polygons they are valid but they some time have z value.... St_isvalid drop z value.
below is the result when i use 
SELECT ST_Multi(ST_Union(the_geom)) FROM faces_obj;

"MULTIPOLYGON(((-14161.75 1941.76 2750,-14161.75 2241.76 2750,-9336.75 2241.76 2600,-9336.75 1941.76 2750,-14161.75 1941.76 2600)))"

these polygons are representing 3D box

i need them to be as one record (mutlipolygon insted of having them in as faces in several rows.

thank you 

Ihab 

Hello 

I have the following table which has polygons, i need to create a multipolygon from these polygons
i tried to use the following query, but the result are strange

331;"POLYGON((-14161.75 2241.76 2600,-14161.75 2241.76 2900,-14161.75 1941.76 2900,-14161.75 1941.76 2600,-14161.75 2241.76 2600))"
338;"POLYGON((-9336.75 2241.76 2600,-9336.75 2241.76 2900,-9336.75 1941.76 2900,-9336.75 1941.76 2600,-9336.75 2241.76 2600))"
341;"POLYGON((-14161.75 1941.76 2600,-14161.75 2241.76 2600,-9336.75 2241.76 2600,-9336.75 1941.76 2600,-14161.75 1941.76 2600))"
344;"POLYGON((-14161.75 1941.76 2900,-14161.75 1941.76 2600,-9336.75 1941.76 2600,-9336.75 1941.76 2900,-14161.75 1941.76 2900))"
347;"POLYGON((-14161.75 2241.76 2900,-14161.75 1941.76 2900,-9336.75 1941.76 2900,-9336.75 2241.76 2900,-14161.75 2241.76 2900))"
350;"POLYGON((-14161.75 2241.76 2600,-14161.75 2241.76 2900,-9336.75 2241.76 2900,-9336.75 2241.76 2600,-14161.75 2241.76 2600))"
331;"POLYGON((-14161.75 2241.76 2600,-14161.75 2241.76 2900,-14161.75 1941.76 2900,-14161.75 1941.76 2600,-14161.75 2241.76 2600))"

SELECT asEwkt(ST_Multi(ST_Union(ARRAY(SELECT the_geom FROM faces_obj))));

the result

"MULTIPOLYGON(((-14161.75 1941.76 2750,-14161.75 2241.76 2750,-9336.75 2241.76 2600,-9336.75 1941.76 2750,-14161.75 1941.76 2600)))"

Kind regards

Ihab 


  

eehab hamzeh wrote:
> SELECT asEwkt(ST_Multi(ST_Union(ARRAY(SELECT the_geom FROM faces_obj))));

Hi,

Did you try to simply do :

SELECT ST_Multi(ST_Union(the_geom)) FROM faces_obj;

The ST_Union function will merge polygons if it is possible.

BTW, some of you polygons are invalid (check them with ST_IsValid). For 
example the first one :

> # SELECT ST_IsValid('POLYGON((-14161.75 2241.76 2600,-14161.75 2241.76 2900,-14161.75 1941.76 2900,-14161.75 1941.76 2600,-14161.75 2241.76 2600))');
> NOTICE:  Too few points in geometry component at or near point -14161.8 2241.76 2600
>  st_isvalid 
> ------------
>  f

-- 
Maxime






 		 	   		  
_________________________________________________________________
Windows Live™: Keep your life in sync. Check it out!
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090924/160dcffb/attachment.html>


More information about the postgis-users mailing list