Horizontal and vertical distance for geospatial points in R?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Horizontal and vertical distance for geospatial points in R?



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


x


y


p1


p2



Shall I find the M coordinate by :


M


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



and then compute x and y by :


x


y


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.


p3


p1


x


distm





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 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
– user9112767
Aug 10 at 17:04


x^2 + y^2


dist^2


x


y


x^2+y^2 = dist^2





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 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 ?
– user9112767
Aug 10 at 17:15


x


y


x^2+y^2=dist^2





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 at 17:22









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS