[postgis-users] Difference between ST_Union and ST_Collect

Luca Morandini lmorandini at ieee.org
Thu May 24 20:52:45 PDT 2012


Folks,

after seeing some polygons disappear during the generalization process, I found 
out that ST_Union and ST_Collect are different beasts when dealing with 
intersecting lines.

I did generalization by: breaking original polygons into lines, generalizing them 
and them assembling back lines into (multi) polygons.

At first I used ST_Collect for the last step:
ST_Multi(ST_BuildArea(ST_Collect(r2.wkb_geometry)))

...but some of the lines intersected, especially over intricate coastlines, 
causing big polygons to be silently dropped.

But when I switched to ST_union:
ST_Multi(ST_BuildArea(ST_Union(r2.wkb_geometry)))

all polygons where built (except for the ones that had to be dropped because their 
area was 0, usually islets).

Is this by design (I wasn't able to find documentation on the different behaviour 
of these two functions) ?

Regards,

P.S.
Sandro, I did not forget to help speeding up the topology construction routines, 
it is just that next week we have a deadline, hence I gave a lower priority to the 
task of setting up a machine with the configuration you requested... stay tuned.

Luca Morandini
Data Architect - AURIN project
Department of Computing and Information Systems
University of Melbourne




More information about the postgis-users mailing list