# QGIS, CRSs and metric measurements of distance matrix and nearest neighbour? [closed]

I have thousands of points on a multiple layers and I need to get the distances between each point and every other point within a layer (so i can get min, max, mean and median distances) and the nearest neighbour values. I have used the distance matrix to achieve distances between each point, and the nearest neighbour tool to get the nearest neighbour value.

It all seemed to be working fine until I realised that the distance values are wrong. I assumed they were in km as the measuring tool displayed the distances of known distances correctly. However, when running it through the distance matrix and nearest neighbour, the values are massively different. In a similar vein to this question: Getting result in metric from QGIS Distance Matrix tool in QGIS?

• Example:
• Point 1 to Point 2 is 1.12km in reality
• Manual measuring tool on QGIS says 1.12km
• Distance matrix says 0.010682
• Nearest neighbour mean observed distance says 0.010682

I have tried changing CRS and reprojecting and saving as a new shapefile, but it still doesn't work. I can get the measuring tool to display the correct measurements but as soon as i run it through the distance matrix or the nearest neighbour i get the same wrong values no matter what the CRS is.

I thought it might be in degrees, but how do I then convert it to km's so when I am writing up my results I can say that 'the mean value was Xkm' rather than some obscure number which doesn't readily mean anything to anyone?

Is there a projection I should be using (my points are plotted from long/lat)?

Is there a setting I need to change for the plugins?

Is there another tool which will do this for larger numbers of points? I

s there a formula I can use to change all the 'wrong' values (possibly degrees) into m/km's?

I don't know python, but is there a clever bit of code I can use to do this?

This worked for a while, but now it's reverted again. I managed to batch execute the reprojection, and then batch distance matrix and nearest neighbour and it seemed to work. For all except one layer. I've tried reprojecting just one file using save as manually, but it won't work. I've installed it on a second computer and tried it won't work. I went back to the original data, imported it into QGIS from csv, straight into ESPG:27700 with the project set to ESPG:27700 and it's still measuring in degrees. It's not the coord's, i've checked and know what the measurements should be. I then ran it with the second year of data ready to disregard one bad file, and it is refusing to work. I really don't understand the problem.

It says it's reprojected the file, but it isn't, or it is but something is making QGIS continue to measure in degrees. I didn't changed any settings from the set which worked, to the set which didn't.

Is this a glitch in the program?

Is there another free GIS program that can do distance matrix and nearest neighbour which might save me this continuous circling?

I have just taken an original unsplit file and reprojected the entire year as one file. I saved and then split it by date, before using distance matrix. It is still running and outputting files and this is likely to take some time but the first couple of outputs so far appear to be in metres. I believe the problems I am experiencing are related to a bug. I will try to report it as such, but for anyone experiencing similar problems all I can suggest is that you disregard any files which aren't working and start right from the very beginning with the data, reprojecting before any other analysis as it seems something lodges itself in the file and stops it working properly when you try to run distance related analysis at some point.

## closed as too broad by PolyGeo♦Mar 10 at 12:14

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• How do i do that, my points are all in mainland britain? I've cycled through so many CRS's trying to find the 'right' one and nothing seems to help. :( – Madbirdhouse Jul 24 '14 at 12:12
• I was about to say 'tried that', but thought 'sod it, I'll give it another go anyway' and it's come up as 1119.109 (assuming metres)! What's annoying is that I was doing that last night and it was still displaying wrongly. So now I'll give it a go with my larger dataset (rather than my test cases of known distances) and we'll see if it works... I've just uninstalled qgis 2.2 and installed 2.4 so maybe there was a glitch in the old installation. Still don't know why it wouldn't work last night - annoying! Thank you so much for making me try it again though! – Madbirdhouse Jul 24 '14 at 12:31
• You surely missed my last sentence in first try ;-) – AndreJ Jul 24 '14 at 12:45

But: Don't use `Set CRS for Layer`, instead `Save As..` under another name with changed CRS.