I was wondering if it's possible to remove any overlapping areas that occurs in a column based on a sample of the table for the shapefile with 2 important columns:
- Shape area
- Geom
I'm trying to find the total shape areas without any overlaps.
I think it's best to minus the sum of the shape area with ST_Intersection but the function needs with 2 different geom:
geography ST_Intersection( geography geogA , geography geogB ) which I took from the PostGIS site. I feel like I'm really close to figuring it out ie. if the table is called "table", then something like this:
SELECT sum(A.shape_area) as "sum with overlaps",
ST_Area(ST_Intersection(A.geom, B.geom)) AS "intersected area"
FROM table A
JOIN table B ON ST_Contains(A.geom, B.geom)
GROUP BY a.geom, B.geom;
But as you can see, my results were off as the sum - intersected area should be bigger than 0. Can someone point out my mistake?
Basically, my goal is to count any area once (regardless of the overlaps)

B.id > A.id. I wouldn't trust the comparison operator forGROUP BYgeometries to function correctly. – Vince May 21 '22 at 18:06idinstead ofprio) and can only remove overlaps non-symmetrically, e.g. when two polygons overlap, only one of them gets reduced - creating an equal cut in both is highly complex (and expinentially so for cases where more than two overlap each other). – geozelot May 21 '22 at 20:20