Reputation: 21
Several of the same geometries appears in the database. I an output with only one object_id for every distinct geometry.
I have managed to get a result with two overlapping geometries.
SELECT
a.objekt_id,
b.objekt_id,
a.geometri
b.geometri
from
plandk.theme_pdk_tilslutningspligtomraade_vedtaget_v a,
plandk.theme_pdk_tilslutningspligtomraade_vedtaget_v b
WHERE
ST_EQUALS(a.geometri, b.geometri)
AND
a.objekt_id != b.objekt_id;
The result is a table showing a row for two overlapping geometries. Though sometimes there are three rows with six overlapping geometries. I want the result to have all these in one row.
Upvotes: 2
Views: 2473
Reputation: 980
DELETE FROM plandk.theme_pdk_tilslutningspligtomraade_vedtaget_v t
WHERE EXISTS (SELECT FROM plandk.theme_pdk_tilslutningspligtomraade_vedtaget_v t2
WHERE t.objekt_id > t2.objekt_id
AND ST_EQUALS(a.geometri, b.geometri))
It will delete all doubled geometries except this with lowest id for each equal geometry group.
Upvotes: 1