לאה פּאַסטעך לאה פּאַסטעך - 3 months ago 12
R Question

How to measure distance between coordinate data (x-Point, y-point) to a specific point of reference (using R)

I need help! I have a list of points (mydata X, Y = latitude, longitude) wich I want to set in relation towards a single Point (for example 287, 347). I just want to measure (and polt) the distance between the list of points towards this single point of reference. But I don't get it. I tried PCA, but there I can't set my specific point of reference.

Does anyone has an idea how to do this?

mydata:

X,Y
260,204
409,208
260,60
272,181
367,257
315,208
381,294
66,333
246,220
330,207
342,304
...

Answer

Using the distance formula, this is a trivial calculation:

mydata$distance = sqrt((mydata$X - 287)^2 + (mydata$Y - 347)^2)

I'm not sure what sort of plot you would like of distance - perhaps a histogram?

hist(mydata$distance)
Comments