3

I have a point layer:

enter image description here

and I would like to calculate and visualize interdistances among the points with lines automatically to see if there is any trend.

The main issue is that if I connect all the points (using for instance solutions shown here) all the points are connected, getting unrealistic results for my purposes (each point represents a city).

What I would like to obtain (green) is something like this:

enter image description here

And what I would not like to obtain (red) is something like this:

enter image description here

I am not sure a completely automated method exists, maybe some manual edits will always be needed. And, of course, I am asking this because I would like to avoid using any buffer, i.e. setting an interdistance value before the analysis.

HyPhens
  • 516
  • 2
  • 19
  • 1
    Your question is unclear. A point (in the image) has only one closest point. "Lines in the image" and "lines should connect the closest points" don't match. – Kadir Şahbaz Jul 06 '23 at 11:11
  • @KadirŞahbaz, what I meant is that, for instance, the upper point on the left should not connect with the lower point on the right, and lines should not cross each others. I can edit the question accordingly. – HyPhens Jul 06 '23 at 11:16
  • 2
    The 2nd image is the final result you need? – Kadir Şahbaz Jul 06 '23 at 11:20
  • 3
    Like the Delaunay triangulation : https://docs.qgis.org/3.28/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html?#delaunay-triangulation ? – J. Monticolo Jul 07 '23 at 07:40
  • 2
    @HyPhens: can you edit your question and describe all the context and things you want. For example here, a delaunay triangulation seems to answers your need, but you specify in your last comment you want the interdistances. It's better to be the more precise at start, you'll have more chance to have a great answer. – J. Monticolo Jul 07 '23 at 07:59
  • @J.Monticolo, yes, I will rephrase the entire question. – HyPhens Jul 07 '23 at 08:06

1 Answers1

4

I dont know if this will give you the results you want?

  1. Delaunay triangulation to create polygons
  2. Polygons to lines
  3. Explode lines to split each line at the vertices
  4. Drop duplicate geometries

enter image description here

If you get "unrealistic" long lines you can filter them with an expression. For example add an "Extract by expression" after Drop duplicate lines.

With your point data this expression will exclude your red lines. "Extract lines shorter than 1.7*mean line length":

 $length<= 
 1.7*aggregate( layer:='Cleaned', aggregate:='mean', 
 expression:=$length

enter image description here

BERA
  • 72,339
  • 13
  • 72
  • 161
  • 1
    Thanks @BERA for this another great answer. I think it answers almost the question, but it some cases, it will give some "unrealistic" distances like the red line at the right in te OP's post. – J. Monticolo Jul 07 '23 at 08:50
  • Bera and @J. Monticolo, is Delaunay Triangulation In QGIS unique for every dataset, or different outputs are possible? Because I think that in geometry some alternative results can be possible (and in my case it would change the distance values). – HyPhens Jul 07 '23 at 09:08
  • https://en.wikipedia.org/wiki/Delaunay_triangulation : unique for a dataset. – J. Monticolo Jul 07 '23 at 09:10
  • 1
    Bera and @J.Monticolo, I still think that Delaunay Triangulation offers multiple possible solutions (for instance, think of an irregular rhombus), but it's probably the best solution available other than drawing manually every connection. If so, I will accept the answer. – HyPhens Jul 10 '23 at 07:44
  • 1
    I've executed the algorithm (the model) 1000 times each on two different point datasets and the result was the same on all iterations – BERA Jul 13 '23 at 15:26