Thursday 25 April 2019

geoprocessing - 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:


enter image description here


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"


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...