[postgis-tickets] [PostGIS] #4840: ST_Azimuth with geography provides wrong results
PostGIS
trac at osgeo.org
Wed Feb 3 01:45:58 PST 2021
#4840: ST_Azimuth with geography provides wrong results
----------------------+---------------------------
Reporter: postlude | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.1.2
Component: postgis | Version: 3.1.x
Keywords: |
----------------------+---------------------------
Hi,
I noticed that the azimuth angles reported by ST_Azimuth are obviously
wrong in some cases.
The following simple example demonstrates this. The central point C is
located at 5°E,55°N. All other points are shifted by 1° in the respective
directions:
{{{
SELECT
degrees(ST_azimuth(C,N)) AS az_n,
degrees(ST_azimuth(C,NE)) AS az_ne,
degrees(ST_azimuth(C,E)) AS az_e,
degrees(ST_azimuth(C,SE)) AS az_se,
degrees(ST_azimuth(C,S)) AS az_s,
degrees(ST_azimuth(C,SW)) AS az_sw,
degrees(ST_azimuth(C,W)) AS az_w,
degrees(ST_azimuth(C,NW)) AS az_nw
FROM (SELECT
ST_GeogFromText('SRID=4326;POINT(5 55)') AS C,
ST_GeogFromText('SRID=4326;POINT(5 56)') AS N,
ST_GeogFromText('SRID=4326;POINT(6 56)') AS NE,
ST_GeogFromText('SRID=4326;POINT(6 55)') AS E,
ST_GeogFromText('SRID=4326;POINT(6 54)') AS SE,
ST_GeogFromText('SRID=4326;POINT(5 54)') AS S,
ST_GeogFromText('SRID=4326;POINT(4 54)') AS SW,
ST_GeogFromText('SRID=4326;POINT(4 55)') AS W,
ST_GeogFromText('SRID=4326;POINT(4 56)') AS NW ) points
}}}
The result is (I manually removed some decimals for easier readability)
{{{
az_n | az_ne | az_e | az_se | az_s | az_sw | az_w | az_nw
------+-------+-------+--------+------+--------+--------+-------
180 | 29.16 | 89.59 | 149.39 | 360 | 329.39 | 269.59 | 209.16
}}}
This is not what I expect. I am well aware that a difference of 1° in N
and E does not result in an azimuth of 45° due to the convergence of the
meridians. The azimuth angles az_ne, az_e, az_se and az_w seem correct (I
checked these angles in a conformal map projection in QGIS). However, what
I expect is
{{{
az_n | az_ne | az_e | az_se | az_s | az_sw | az_w | az_nw
------+-------+-------+--------+------+--------+--------+-------
0 ! | 29.16 | 89.59 | 149.39 | 180 !| 211 ! | 269.59 | 331 !
}}}
What was going wrong for az_n, az_s, az_sw and az_nw?
The version of my DB is
{{{
version
| postgis_version
---------------------------------------------------------------------------------------------------------------------------------+---------------------------------------
PostgreSQL 13.1 (Ubuntu 13.1-1.pgdg18.04+1) on x86_64-pc-linux-gnu,
compiled by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, 64-bit | 3.1
USE_GEOS=1 USE_PROJ=1 USE_STATS=1
}}}
installed via the apt.postgresql.org repositories for Ubuntu 18.04.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4840>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list