I'm trying to calculate the shortest distance between a line (described as a pair of [lat, long]s) and a point (lat, long) accurately. I've read many Wikipedia pages, but I'm new to the topic. I've read this question, but I'm still confused, because they say that

Literally, a "straight line" will pass beneath the earth's surface.

while my line lies on the surface of the Earth. How can I calculate this?

  • What software are you using? – Maksim Sep 24 '14 at 14:09
  • I'm not using any software, just need this calculation in a project. (A Java project, if it matters.) – Aron Lorincz Sep 24 '14 at 14:11

If you know postgis, you can create the shortest line between two geometries : http://postgis.net/docs/manual-2.1/ST_ShortestLine.html. Then you can calculate the length with :http://postgis.net/docs/manual-2.1/ST_Length.html

If you dont need to create the line : st_distance should be enough : http://postgis.net/docs/manual-2.1/ST_Distance.html

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.