Re: Wrong distance shown in miles for extension earthdistance

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: ipkis76(at)gmail(dot)com, Pg Docs <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: Wrong distance shown in miles for extension earthdistance
Date: 2021-03-22 08:49:27
Message-ID: CABUevExRh4+=VwhwPH7jbVoMiSvy5sgHS6=hktvwHi9HDBfBJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Mon, Mar 22, 2021 at 9:27 AM PG Doc comments form
<noreply(at)postgresql(dot)org> wrote:
>
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/10/earthdistance.html
> Description:
>
> Hi,
> I have installed
> CREATE EXTENSION CUBE;
> CREATE EXTENSION earthdistance;
>
> Post which I ran the following query:
> SELECT (POINT (19.974, 72.756)<@> POINT (19.195, 72.959)) AS DISTANCE;
>
> The answer came back as 21.17534 miles whereas the actual distance (as crow
> flies) is 55.42 miles which I have checked from 2-3 websites. (Google maps
> gives a greater distance which is travel by road & this value has been
> ignored).
>
> I know both the places and the distance between both of them cannot be 22
> miles. It has to be in excess of 50 miles atleast. What am I missing?

By your queasy it looks like you are comparing two points in the Norwegian Sea.

I think you may have swapped your latitude and longitude, and are
actually looking for:

postgres=# SELECT (POINT (72.756, 19.974)<@> POINT (72.959, 19.195))
AS DISTANCE;
distance
--------------------
55.421996899143366

--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2021-03-22 12:31:08 ssl connection with certificate
Previous Message PG Doc comments form 2021-03-22 04:17:42 Wrong distance shown in miles for extension earthdistance