2

I have a rather large dataset that contains duplicated lines with an offset of 1m-5m and I want to find an efficient way to solve this problem using QGIS. Is there anyway in QGIS to find the lines that have a specific distance between them?

  • My first idea: if the lines are duplicates then length and number of vertices must be pairwise equal. Maybe you can identify the pairs by joining the layer with a copy of itself on fields containing the length and number of vertices, not having the same fid. If the they are not exactly equal they are completely within a buffer of say 10 m around the counterpart. – Detlev Jun 3 '15 at 7:03
  • 2
    if you are familiar with postgis pseudo query: select a.gid, g1.gid FROM ( SELECT gid, st_offset(-1*st_X(geom), -1*st_y(geom) geom) g from a)) g1 , a WHERE a.gid != g1.gid AND st_equals(g.geom, g1.geom) IS TRUE AND st_dwithin(a.geom, g1,geom , 10 ) That would return all gid from table which are same when moved to 0,0 and are within 10 units from each other in original coordinates How to do it in qgis , no idea – simplexio Jun 3 '15 at 10:25
2

Just followed the comment by @simplexio. (by a Virtual Layer).

(1) Go to Layer | Add Layer | Add/Edit Virtual Layer

(2) [Import] line dataset (many_lines in the following example)

(3) Query: (within 5m)

SELECT * FROM many_lines a
CROSS JOIN many_lines b
ON a.id<> b.id AND st_intersects(st_buffer(a.geometry, 5), st_buffer(b.geometry, 5))=1

To test various offset (1~5m), please change 5 in the above syntax to other values.

(4) Create a buffer of 5m for the virtual layer to check visually.

enter image description here

And the attribute table of the Virtual Layer will look like this:

enter image description here Please note duplicates like 0-1, 1-0 pair, 0-2, 2-0 pair, ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.