More

PostGIS “Overlay” Style Union, not “Dissolve” Style

PostGIS “Overlay” Style Union, not “Dissolve” Style


I'm trying to use PostGIS to do a 'union' of polygons. When I Googled "PostGIS Union", I found the ST_Union function, which performs what I would call a 'dissolve,' not a Union. What I actually want to do is what GRASS refers to as an "Overlay" with the "OR" operator, or QGIS/ArcGIS just simply call a "Union." For example:

From what I can tell, in PostGIS it appears I need to use both ST_Intersection and ST_SymDifference together to get the results I am seeking. I have had some success with the following syntax, but it's terribly inefficient. Is there a better/more efficient way to do what I'm hoping to accomplish?

INSERT INTO "CombinedResults" ("geom") SELECT ST_SymDifference( "test1".GEOM ,"test2".GEOM ) FROM "test1","test2"; INSERT INTO "CombinedResults" ("geom") SELECT ST_Intersection( "test1".GEOM ,"test2".GEOM ) FROM "test1","test2"

Maybe ST_ConvexHull will help you. See this snippet to understand how it works http://www.bostongis.com/postgis_concavehull.snippet