I have lines overlapping in one layer as in image below. How do I delete one of these lines and leave the other one in the dataset?
you can use an SQL query to delete them.
Before doing so, be warned that it can lead to surprises should more than 2 lines intersects each others. It is also suspicious to delete a random line between the two intersecting ones. --> make a backup before deleting anything.
That being said, the query would refer twice to the same table: once for deleting the rows and once for identifying intersecting rows.
tmp.id < t1.id is used to delete the line having the smallest ID between the two intersecting ones. It also filter self deletion (a line intersects itself)
DELETE FROM t1 WHERE EXISTS ( SELECT 1 FROM t1 tmp WHERE tmp.id < t1.id AND ST_INTERSECTS(tmp.geom, t1.geom));