[GIS] Checking for overlapping geometries in one table using PostGIS

overlapping-featurespostgis

I have a table with geometries where some geometries overlaps with other geometries in the same table.

I already found an answer for this question here:
Check whether table has overlapping polygons, in PostGIS?

But when I try to create a view of the query as result I do not get any geometries for the query only a table, this also helps a lot but with geometries it would help even more.

The query is

SELECT *
FROM schema.table1 a
INNER JOIN schema.table1 b ON 
(a.geom && b.geom AND ST_Overlaps(a.geom, b.geom))
WHERE a.id != b.id;

With this query I get the table and if I substitute st_overlaps with st_intersection I get the query error that the intersection must be type boolean and not type geometry.

Best Answer

Download the PostGIS Addons from this link: https://github.com/pedrogit/postgisaddons

Install by running the postgis_addons.sql file to get the ST_GeoTableSummary() function.

Test by running the postgis_addons_test.sql file.

Search for ST_GeoTableSummary() in the file. The function is documented.

This query identifies overlapping parts in a table:

CREATE TABLE test_geotable_summary AS
SELECT * FROM ST_GeoTableSummary('public', 'test_geotable', 'geom', 'id');

If you want to remove the overlaps tou can use the ST_RemoveOverlaps() function.