1

My question is based upon this question. I would like to have horizontal and vertical distance shown as x and y below, between 2 geospatial points p1 and p2. enter image description here

Shall I find the M coordinate by :

M$lat = p1$lat
M$lon = p2$lon

and then compute x and y by :

x = distm(p1,M,fun = distHaversine)
y = distm(p1,M,fun = distHaversine)

Or there is a straightforward method to do this? In addition, How could I define a direction ? Imagine we have p3 on the left side of p1, then the new x will have the opposite direction, which with distm I'm not able to catch it.

5
  • 1
    Does horizontal and vertical mean same lon and lat? Like M has the same lon as P2 and the same lat as P1? This is implied by your attempt, but you have to decide what you want horizontal and vertical to mean. Because otherwise we could be in any projection. In particular, note that with this definition x^2 + y^2 will not equal dist^2
    – Calum You
    Aug 10, 2018 at 16:12
  • @CalumYou, oh ! Why x^2 + y^2 is not equal to dist^2 ?? I'm looking exactly for x and y that I have x^2+y^2 = dist^2
    – Haribo
    Aug 10, 2018 at 17:04
  • 1
    Because you are probably on a sphere (or the earth's spheroid) if you are doing lat lon calculations, and flat plane geometry doesn't hold. it is close enough for small distances but at large ones it isn't. think about the triangle with equal sides with a corner at the north pole and two on the equator. the two lower corner angles are both "90 degrees".
    – Calum You
    Aug 10, 2018 at 17:09
  • @CalumYou, That's correct! So do you have an Idea how should I compute the x and y in a way that x^2+y^2=dist^2 holds ?
    – Haribo
    Aug 10, 2018 at 17:15
  • It will depend on your use case... you can reproject your points to a flat projection but you will have to decide what makes the most sense for you. try asking in the chat
    – Calum You
    Aug 10, 2018 at 17:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.