I am trying to use the ST_Difference tool within PostGIS. The intention is to take two multipolyogn layers that have some overlap and eliminate the overlap by taking the difference.
The problem is that I am using two multipolygon tables as input but the output table is a polygon type.
Information seems to be lost (the individual division of the polygon). The output is indeed differenced, but it is one polygon without the original divisions included. What is making this query change geometry types?
SELECT ST_GeometryType(divided1.geom)
FROM divided1;
--st_geometrytype
--ST_MultiPolygon
The geometry of the 2nd table is the same type.
CREATE TABLE box_diff AS
SELECT divided_1.cat, ROW_NUMBER () OVER(), ST_Difference(divided1.geom, divided2.geom) AS geom
FROM divided1, divided2;
Then the geometry type of the created table is
SELECT ST_GeometryType(box_diff.geom)
FROM box_diff;
--st_geometrytype
--ST_Polygon
This image shows two screen shots of two spatial tables in PostGIS. They were created by taking a buffer of a file similar to a road network, and then in QGIS I used the polygon divide tool to make evenly sized boxes. The north-south lines have overlap with the east-west lines and I wish to remove the overlap by using the difference function. If you can suggest a better tool please let me know
