1

This question already has an answer here:

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?

marked as duplicate by radouxju, Erica, user30184, Jason Scheirer, underdark Sep 24 '14 at 19:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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
1

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

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