Why am I getting different results?

  ST_GeographyFromText('SRID=4326;POINT(13.401111 52.383343)'), --berlin
  ST_GeographyFromText('SRID=4326;POINT(9.997559 53.533778)') --hamburg

= 262077.401614256

  ST_SetSRID(ST_MakePoint(13.401111, 52.383343), 4326),
  ST_SetSRID(ST_MakePoint(9.997559, 53.533778), 4326)

= 3.592724162238034

The first result looks a lot closer to reality ;-)

Edit: had to cast the points in the second query to geography.

    ST_SetSRID(ST_MakePoint(13.401111, 52.383343), 4326)::geography,
    ST_SetSRID(ST_MakePoint(9.997559, 53.533778), 4326)::geography

Still don't really understand why I have to do this. Isn't SRID=4326 enough for ST_DISTANCE to know what type of point I am passing?

1 Answer 1


ST_Distance (folowing the documentation) - For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.

So - if you'll feed it with geometry,4326 you'll get distance in units of 4326 which is degrees; if you'll feed it with geography you'll get distance in meters..

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.