GenericMappingTools / GenericMappingTools/gmt

Incorrect formula for centroid of spherical triangle (plus inaccurate area formula)

Open
#5,331 2 comments 0 reactions 1 assignee Claimed by @PaulWessel View on GitHub
bug
Dominant language
C
Stars
979
Forks
414
Avg merge
17h 26m
Merged PRs (30d)
54

Description

The formula used for the centroid of a spherical triangle in
gmtlib_geo_centroid_area (take the 3d mean of the three vertices and
normalize). An example where you clearly get the wrong answer is given
by whuber in

https://gis.stackexchange.com/questions/43505/calculating-a-spherical-polygon-centroid

The right formula is given by Brock (1975)

https://doi.org/10.1115/1.3423535

This easily generalizes to a polygon (without the need to break the
polygon into triangles).

While on the subject of gmtlib_geo_centroid_area, I'll note that the
method of computing the area (a direct calculation of the spherical
excess) is terribly inaccurate for small areas. I recommend instead the
formula given in

https://en.wikipedia.org/wiki/Spherical_trigonometry#From_latitude_and_longitude

Here again this formula can naturally be applied to a polygon (although
care needs to be taken if the polygon encircles a pole).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.