We are trying to merge two Multipolygons which are stored in our PostGIS 2.1 database without losing the boundaries that are contained in each Multipolygon.
Our spatial data matches the following criteria.
-- Check whether the polygons share points (boundaries?)
-- ST_Intersects:
-- Returns TRUE if the Geometries/Geography "spatially intersect in 2D" - (share any portion of space)
-- and FALSE if they don't (they are Disjoint).
ST_Intersects(higher_geom,lower_geom) = TRUE
-- ST_Crosses:
-- Returns TRUE if the supplied geometries have some, but not all, interior points in common.
ST_Crosses(higher_geom,lower_geom) = FALSE
-- Since ST_Crosses would return FALSE if the polygons have all interior points in common
-- we have to ensure this is not the case
ST_Within(higher_geom,lower_geom) = FALSE
If we then try to aggregate the columns lower_geom and higher_geom (both of type MultiPolygon) with the following query, the result of ST_Union is lacking the borders of the original polygons.
SELECT
ST_Union(lower_geom, higher_geom)
FROM
myTable
To make it more clear, we have added a screenshot. In our desired result, both, the green and the red multipolygons should be contained in ONE new multipolygons still containing ALL boundaries.
Does anyone have an idea!?
Thanks in advance, Cord & Martin