[postgis-users] Combined MULTIPOLYGON from subselect on column containing MULTIPOLYGON?

Christian Schwartze christian.schwartze at uni-jena.de
Sun Jan 27 08:38:45 PST 2008


I don't know if my comment is very helpful but your problem description
returns a former similar issue to my mind: I had to translate and
aggregate single polygons - stupidly formatted as MULTIPOLYGON - to only
one exclusive POLYGON: I used the geometryn function to retrieve the
first (and only) poly, and combined it with the collect():

select collect(geometryn(geom, 1)) from ... 

Regards,
Christian.


Am Sonntag, den 27.01.2008, 10:03 +0100 schrieb Marcus Jenkins:
> Hi
> 
> I'm trying to make a (new, larger) multipolygon from a number of rows
> that are selected using an aggregate function ST_Collect.  The problem
> is that the ST_Collect creates a geometrycollection which I can't work
> out how to merge into a new multipolygon, even though the source
> column only contained multipolygon.  I've RTFM a few times...
> ...help?!
> 
> My current insert statement looks something like this - I get no
> error, but the output is null in the output column.
> 
> insert into my_output_table (id, the_geom, debug_text) select s.id,
> ST_MPolyFromText(ST_AsText(ST_Collect(s.the_geom))),
> ST_AsText(ST_Collect(s.the_geom)) from my_source_table s group by id;
> 
> The debug_text column gets filled with lots of nice WKT of
> GEOMETRYCOLLECTION, but we kind of expected that already ;-)
> 
> Any clues greatly appreciated.  Otherwise I will be forced to do
> something horrible in Perl like do the select, dismember each
> MULTIPOLYGON record in the source table grouped as per the  select
> above and then craft WKT to make an insert statement to populate my
> output table.  /Surely/ I don't have to resort to this kludgery?
> 
> Regards
> 
> Marcus
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list