# How to calculate distance between points (with UTM coordinates) in Rstudio?

I have points on a QGIS map, and want to determine the distance between each of the points in Rstudio. Each Unique ID is a tree. The coordinates are UTM coordinates (x = East, y = North)

My dataset looks like this:

Unique_ID EW_X EW_Y
45 573500 775011
49 572224 774700
70 573573 775200
71 573573 775200

What formula would I use so I can get an output that describes the distance between each tree, looking like this (where x is the distance between each tree):

Unique_ID 45 49 70 71
45 x x x
49 x x x
70 x x x
71 x x x

Or perhaps if it is more simple, repeated rows (e.g. 45 against 49, 45 against 70, 45 against 71; and etc. with each repetition being a new row).

• Are you looking for help with the mathematical formula to calculate the distance between UTM coordinates or with how to code this in R? Commented Aug 6, 2021 at 13:50
• How to code this in R - if I've published this question on the wrong Stackexchange website my apologies! Commented Aug 6, 2021 at 20:06