[postgis-users] Get more polygon's exterior boundary

Nicolas Ribot nicky666 at gmail.com
Thu Mar 27 06:51:17 PDT 2008


>
>  If I have some POLYGON in the subjunctive table:
>
>  DROP TABLE IF EXISTS try;
>  CREATE TABLE try
>  ( id serial NOT NULL,
>   the_name character varying(10),
>   the_geom geometry,
>   CONSTRAINT pk_try PRIMARY KEY (id));
>
>  INSERT INTO try (the_name, the_geom) VALUES ('1A',
>  GeomFromText('POLYGON((10 10,10 20,20 20,20 10,10 10),(13 18,18 18,18
>  13,13 13,13 18))',-1));
>  INSERT INTO try (the_name, the_geom) VALUES ('1B',
>  GeomFromText('POLYGON((13 18,18 18,18 13,13 13,13 18))',-1));
>  INSERT INTO try (the_name, the_geom) VALUES ('2',
>  GeomFromText('POLYGON((20 10,20 20,30 20,30 10,20 10))',-1));
>  INSERT INTO try (the_name, the_geom) VALUES ('3',
>  GeomFromText('POLYGON((10 20,10 30,30 30,30 20,20 20,10 20),(13 23,23
>  23,23 28,13 28,13 23))',-1));
>
>  How can I get the next polygon?
>  POLYGON((10 10, 10 20,10 30,30 30,30 20,30 10,10 20,10 10),(13 23,23
>  23,23 28,13 28,13 23))
>

Hi, maybe you meant this polygon ?

POLYGON((10 10, 10 20,10 30,30 30,30 20,30 10,10 10),(13 23,23 23,23
28,13 28,13 23))

(yours is not a valid polygon because of the (10,20) last coordinates
pair in the first ring, if you wanted to express the union of all
polygons).

You can obtain it by getting the union of the polygons in the try
table, something like:

select st_astext(geomunion(the_geom)) from try;

st_astext was used for representation only

Nicolas



More information about the postgis-users mailing list