0

I want to calculate the distance in meters between two points but I am getting an obscene result 5497980.47338251

Here is the query I made:

SELECT ST_Distance(ST_SeTSRID(ST_MakePoint(6761331.47, 2873883.72), 2154), 
                   ST_SeTSRID(ST_MakePoint(2873464.28, 6761335.07), 2154)),
       ST_Distance(ST_MakePoint(6761331.47, 2873883.72), 
                   ST_MakePoint(2873464.28, 6761335.07))

The coordinates are in the 2154 SRID.

What should I do to get a good result? I tried with the 4326 SRID and the appropriate coordinates and got a wrong answer as well.

  • 3
    I think you mixed x and y in one of the ST_MakePoint, the result should be meters! – ThingumaBob Aug 22 at 16:26
3

As was mentioned by @ThingumaBob playing around with coordinates order will give better output

SELECT ST_Distance(ST_SeTSRID(ST_MakePoint(6761331.47, 2873883.72), 2154),
       ST_SeTSRID(ST_MakePoint(6761335.07, 2873464.28), 2154)) AS dist

dist = 419.4554488862289 meters, EPSG:2154.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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