title: How can I get distance between two points on Earth from PostGIS?
body: <p>I'm getting an unexpected value from a PostGIS distance query, and I'm not sure why. I'm trying to find the distance between two points on Earth.</p>
  
  <pre><code>SELECT ST_Distance(
    ST_Point(50.7678,6.091499)::geography,
    ST_Point(52.525592,13.369545)::geography
  ) as distance;
  </code></pre>
  
  <p>... returns <code>827757.672533206</code>, or about 827.7km.</p>
  
  <p>However, if I calculate this distance with an open source library I'm using, or using any one of several online calculators, I get 538.6km. Something is obviously amiss.</p>
  
  <p>What am I doing wrong?</p>