1

I'm trying to calculate a sample distance matrix from four points in the BNG CRS: enter image description here

Using Vector-> Analysis Tools -> Distance Matrix, I get: Input point layer is a MultiPoint layer - first convert to single points before using this algorithm

**Input point layer is a MultiPoint layer - first convert to single points before using this algorithm**

How can I get a distance matrix from my layer of many points?

Newb
  • 23
  • 3

1 Answers1

4

The error gives also an answer: convert to single points first. This can be done with the algorithm 'Multipart to singleparts'.

You can link both algorithms in the graphical modeller: processing > graphical modeller (or ctrl + alt + m)

  • define as input 'vector layer' and set as point
  • link this with algorithm 'Multipart to singleparts'
  • link output of previous with algorithm 'distance matrix' -> define an output

![enter image description here

Now it should work in one step and can be reproduced for other layers.

PieterB
  • 5,287
  • 22
  • 37
  • I'm not familiar with the graphical modeler (looks super powerful though), so I tried splitting the points via the same command in the toolbox, but it wont let me: layers were not correctly generated – Newb Mar 19 '19 at 17:00
  • UPDATE: created the workflow, but can't add it to my toolbox because shutil.SameFileError: – Newb Mar 19 '19 at 17:18
  • May be this can help. It is not for Qgis 3.x but it works https://gis.stackexchange.com/questions/162120/problem-with-distance-matrix-in-qgis-2-83 – Gerardo Jimenez Mar 19 '19 at 20:55
  • @Newb: I don't know what this error means. But can you share your files? So I can do some tests on it? – PieterB Mar 20 '19 at 08:58
  • 1
    @PieterB, I solved: 'shutil.SameFileError:': QGIS didn't like having the model saved into models path directly. I needed to let it load from another directory. (Basically, QGIS doesn't want to load the model since it was in the models folder, but because it wasn't loaded through QGIS I couldn't access it through the GUI). Hope this helps someone else. – Newb Mar 20 '19 at 12:12
  • @PieterB, Re: layers were not correctly generated error: Here is a sample: https://drive.google.com/drive/folders/12v4p0H6la7doRmliB6awqVrAJKlDyr_7?usp=sharing – Newb Mar 20 '19 at 12:26
  • you better use another algorithm to go from multipoint to point: 'Multipart to singlepart'. I will edit my answer – PieterB Mar 20 '19 at 12:42
  • Worked like a charm – Newb Mar 20 '19 at 12:50