1

I'm trying to calculate the distance between to geographical points, but the calculated distance is bigger than the real one (from Google Maps).

The location column in postgresql is define as geography(Geometry,4326), and the query is:

select ST_Distance(u1.location, u2.location)

For example, I have a pair of points for which the distance is:

  • 160 km on Google Maps
  • 190 km calculated with the above query.

What can be wrong? I may be missing a projection matter.

I have also tried the following query, but I get the same results:

select ST_Distance(ST_GeogFromText(ST_AsText(u1.location)), ST_GeogFromText(ST_AsText(u2.location)))

closed as off-topic by user30184, PolyGeo Oct 25 '15 at 21:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – user30184, PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

1

I got the answer in https://stackoverflow.com/a/10148241/3463640: I had inverted lon & lat when creating points.

  • Yes I tried to do so yesterday, but it appears I have to wait for 2 days. – anthony Oct 26 '15 at 17:28

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