This question is related to Seeking PostGIS equivalent to GeoPandas union overlay?
I have two tables in PostGIS, each with two features(rows) and a rectangular geometry (polygon).
I would like to obtain the Symmetrical Difference from those two layers so that the result would be:
the resulting table has the attributes from the first table (df1), or the second (df2)
However when I try to use ST_SymDifference in PostGIS I get a different result:
CREATE TABLE test.symdifference_v04 AS
SELECT
test.df1.df1,
test.df2.df2,
ST_SymDifference(test.df1.geom,test.df2.geom)
FROM test.df1, test.df2
It seems that the ST_SymDifference is applied on a polygon to polygon basis i.e. df1 row 1 vs df2 row 1
df1 row 1 vs df2 row 2
df1 row 2 vs df2 row 1
df1 row 2 vs df2 row 2
with Multipolygons as a result.
How would I obtain the first mentioned result with the 6 polygons (fancy colors) instead of the 4 multiploygons in PostGIS?