Question

I would like to ask what is the difference between geometry and geography using the PostGIS function ST_Azimuth.

When I execute the following query:

SELECT degrees( ST_Azimuth(ST_MakePoint(21.304116745663165, 38.68607570952619), ST_MakePoint(21.286237118117278,38.71455640443629)) )

I get 327.880195438529 degrees.

But when I cast the geometries to geography as the following query :

SELECT degrees( ST_Azimuth(ST_MakePoint(21.304116745663165, 38.68607570952619)::geography, ST_MakePoint(21.286237118117278,38.71455640443629)::geography) )

I get 333.810802282843 degrees.

Does the cast to geography give a more accurate result? Or a different calculation is made?

My geometries have SRID=4326.

Thank you in advance.

Was it helpful?

Solution

It looks to me as if geography gives you the point-point azimuth on the WGS84 Earth (so an approximately spherical surface) while the geometry gives you the point-point azimuth on the plane.

So, yes, a different calculation is made.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top