I want to determine the distance in meters between two geographic coordinates. The points are:

     Lat (deg)   Lon (deg)
A: -33.3930906 -70.5452765 
B: -33.3993212 -70.5468767

So if i calc the distance in google maps or with a python library the measure is approx. 700 m but when I do the same query (distance) in PostGIS it tells me it is 291 (I don't know the unit, I believe that is meters)

My queries are:

SELECT ST_Distance_sphere(
    st_makepoint(-33.3930906, -70.5452765),
    st_makepoint(-33.3993212, -70.5468767));

SELECT ST_Distance_Sphere(
    ST_Centroid(ST_GeomFromText('POINT(-33.3930906 -70.5452765)',4326)), 
    ST_GeomFromText('POINT(-33.3993212 -70.5468767)',4326));

SELECT ST_Distance(gg1, gg2) As spheroid_dist, 
       ST_Distance(gg1, gg2, false) As sphere_dist
        ST_GeogFromText('SRID=4326;POINT(-33.3930906 -70.5452765)') As gg1,
        ST_GeogFromText('SRID=4326;POINT(-33.3993212 -70.5468767)') As gg2
    ) As foo  ;

And each of the three queries give me a result of approx. 291 or 292.

So, how can I do it?

My original intention is to query all the points in a certain radius. For this I'm using ST_DWithin.

And in my database I store it like:

// Column is
coordinates GEOGRAPHY(Point, 4326)  NOT NULL,
// Insert is
ST_GeographyFromText('POINT(-33.3940301 -70.5482872)', 4326)

1 Answer 1


Your coordinates are out of order. If you reverse the order of coordinates in the first query, postgis says: 708.55982691.

In postgis it's lon, lat, not lat, lon.

  • Happens to the best of us :D
    – Rob Skelly
    Jan 9, 2016 at 19:20

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.