I'm using/learning geodjango + postgis, and I'm trying to calculate distance between 2 cities in Poland. First using WGS84/4326 I define 2 points, and then after transforming this points into spherical mercator 900913 i get distance which is about 40km too long. Which map projection should I use then? Where can I find proper srid's for different countries?

sorry for the delay, 2 cities (lat; long): Slupsk(54.465249;17.026062) and Koszalin(54.193378;16.179428)

  • do you have the latitude and longitude values so we can check? Mar 19, 2012 at 1:52
  • Ideally, questions should stand on their own, without comment. Please edit the extra information, provided in comments above and below, into the body of the question.
    – Martin F
    Apr 21, 2015 at 15:07

3 Answers 3


Use latitude and longitude and the great circle distance, not a map projection.

  • i tried to use pyproj which is python binding for proj4 library. And using 'sphere' ellipsoid i still get distance which is about thirty km too big. g = pyproj.Geod(ellps='sphere') a, b, dist = g.inv(54.186548, 16.177368, 54.465249, 17.026062) dist = 98516.645068962112
    – agend
    Mar 24, 2012 at 17:27
  • 1
    Agend, you appear to have mixed up the latitudes and longitudes. g.inv(16.177368, 54.186548, 17.026062, 54.465249) will return 63335.3 meters, which is 35.1813 kilometers shorter--about what you're looking for.
    – whuber
    Mar 24, 2012 at 20:25
  • so now i'm getting totally lost - will have look at that - thank you
    – agend
    Mar 31, 2012 at 7:04

That's what picking a decent map projection is all about. I don't know your lat/long range but you can query projections relevant to a lat/long bounding box at the EPSG Geodetic Parameter Dataset. This should give some codes to test out.

EDIT: Thanks for posting your coordinates. When you just calculate a cartesian distance between these points in a Plate Carree or something similar projection, you get something like 90km which is obviously the wrong result from a wrong method.

Others have explained the 'math route' using a spherical calculation, so I took the 'tool route' and retrieved the ETRS89 projection from the EPSG database based on your coordinates, measuring in this coordinate system I get about 63km, which is the considerable difference we're seeing.

enter image description here

  • thank you - would u mind explaining me how to find the proper projection for my coordinates on epsg.org page - all i can see there is a bunch of links to same white papers or other thinks which i don't ever try to understand. Thanks in advance
    – agend
    Mar 31, 2012 at 7:06
  • epsg-registry.org is actually the more direct link and will point you to a this dialog without any additional searching around. The most quick/dirty method of choosing a system would be to review the "Area Description" field and pick a ProjectedCRS system that appears to describe your geographical area most specifically (eg "Poland" vs "Europe"). You could do some quick research to see what metric is important to you to preserve in an available projection (distance, area, bearing, etc). However for pure distance, (< 1-2m), you should use one of the geodesic methods below.
    – WolfOdrade
    Apr 2, 2012 at 4:23

Based on the 2 points in your comments:

2 cities (lat; long): Slupsk(54.465249;17.026062) and Koszalin(54.193378;16.179428) 

I used two different approaches. The formula given in The Aviation Formulary I ended up with a distance of 63.116745 KM

I also used this tool Calculate distance, bearing and more between Latitude/Longitude points. I ended up with an answer of 63.16 km.

Both methods use a "cue ball" earth, they do not use WGS84, or any projection.

Your Answer

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

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