I'm working in Postgres 9.5. I have two tables, each with a column geometry(MultiPolygon,4326)
.
I want to creat a single MultiPolygon that is the union of every polygon in the two tables.
I have tried running ST_Union
, but it isn't doing quite what I expected. If I do this:
SELECT
ST_GeometryType(ST_Union(table1.geom, table2.geom))
FROM table1, table2;
This produces lots of MultiPolygon
results, instead of a single one, which suggests to me that the result of a simple ST_Union
is not a single polygon.
What is ST_Union(table1.geom, table2.geom)
actually giving me, conceptually? Why are there multiple polygons?
What do I need to do to get a single multipolygon - something like ST_Union(ST_Union(table1.geom), ST_Union(table2.geom))
?
ST_Union(ST_Collect(t1.geom), ST_Collect(t2.geom))
instead, for efficiency?