3

I have layer of points of which I need to build lines. Standart Points to path function doesn't suit me. I have data on time, but it does not reflect the order of connection that I need. I need to connect them by distance. That is, if the distance between two points is less than 10 meters - draw a line. Is it possible?

  • 1
    I didn't find any tool or I missed. But it can be done using python script. If you prefer python code, I can add as an answer. – Kadir Şahbaz Feb 4 at 0:34
2

If you don't mind working with QGIS' natively supported SQLite dialect, this breaks down to a trivial self-JOIN on the distance threshold:

  • either create a Virtual Layer, or use the DB Manager
  • run (assuming your point source layer is called pts, and has an id column)

    SELECT  a.id,
            b.id,
            MakeLine(a.geometry, b.geometry) AS geometry
    FROM    pts AS a
    JOIN    pts AS b
      ON    ST_Distance(a.geometry, b.geometry, 1) < 10
    WHERE   a.id <> b.id
    ;
    

The optional third parameter to ST_Distance (use_ellipsoid BOOLEAN), if given, will force the function to calculate distances based on a sphere (use_ellipsoid=0) or spheroid (use_ellipsoid=1), rather than on the Cartesian plane; this requires the geometries to be in a geographic reference, but works on meter as unit instead of the unit of the underlying CRS.

Note that this effectively aggregates attributes from two rows; the natively compiled SQLite version doesn't have any array support other than string concatenation. I simply added the id of both points to the output as reference; you could e.g. use the timestamp here.

| improve this answer | |

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.