[postgis-users] Multipolygons to Polygons
Obe, Regina
robe.dnd at cityofboston.gov
Tue Mar 27 05:29:38 PDT 2007
SELECT geometryn(ogc_geom, generate_series(1, numgeometries(ogc_geom))
As poli
FROM test_table
If you need to use this in a viewer that requires a primary key and
entry into geometry_columns table or your table is fairly large, then
you'll need to create a table with something like
CREATE TABLE test_table2(gid serial, CONSTRAINT pk_test_table2 PRIMARY
KEY(gid));
AddGeometryColumn('public', 'test_table2', 'poli', <srid>, 'POLYGON',
2);
INSERT INTO test_table2(poli)
SELECT geometryn(ogc_geom, generate_series(1, numgeometries(ogc_geom))
As poli
FROM test_table;
CREATE INDEX idx_test_table2_poli ON test_table2 USING gist
(poli);
Hope that helps,
Regina
________________________________
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Leticia
Sent: Monday, March 26, 2007 7:17 PM
To: postgis-devel at postgis.refractions.net
Cc: postgis-users at postgis.refractions.net
Subject: [postgis-users] Multipolygons to Polygons
Importance: High
Can I separate the polygons that conform a multipolygon from SQL?
For example, If I query
SELECT AsText(ogc_geom) as poli from test_table
I get:
MULTIPOLYGON(((580525.37 141603.2,580523.3 141629.81,580539.66
141631.09,580540.93 141619.38,580541.46 141608.63,580541.48
141604.73,580525.37 141603.2),(580527.79 141607.36,580532.68
141607.38,580532.61 141622.27,580527.73 141622.26,580527.79 141607.36)))
which consists of 2 polygons....
Can I run a SQL that let me obtain the two separate polygons?
Thanks in advance,
Leticia
-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070327/3a6df900/attachment.html>
More information about the postgis-users
mailing list