Skip to content

the result of turf/ellipse is not exact at high lattitudes #2736

@hadbn

Description

@hadbn

The fonction turf/ellipse has the good behavior when plotting small ellipses at low lattitudes.
However when plotting "big ellipses" close to the poles, the earth curvature is poorly taken into account, leading to problems with the resulting geometry.

Reproduced with Turf version 7.1 running at https://turf-sandbox.netlify.app/ with the following code :

const p = turf.point(
  [0., 60.]
);
const c = turf.polygon(turf.circle(p, 2000).geometry.coordinates, {fill: '#0FF'});
const e = turf.polygon(turf.ellipse(p, 2000, 2000).geometry.coordinates, {fill: '#ff0000'});;

return turf.featureCollection([c, e]);

image

The two geometries should be exactly superimposed. Furthermore, taking the projection into account would mean having a “wider” ellipse on this projection near the pole than near the equator, which is not the case. This is due to the use of rhubDestination instead of destination (which uses the Harvesine formula), which leads to an incorrect calculation of the coordinates of the points of the ellipse.

This second example shows an other issue :

const p = turf.point(
  [0., 60.]
);
const c = turf.polygon(turf.ellipse(p, 2000, 2000, {angle: 0}).geometry.coordinates, {fill: '#0FF'});
const e = turf.polygon(turf.ellipse(p, 2000, 2000, {angle: 90}).geometry.coordinates, {fill: '#ff0000'});;

return turf.featureCollection([c, e]);

image

Once more, both geometry should be exactly superimposed. This time, the imprecision is due to the fact that the geometry is rotated once being completly calculated. This leads to bad behavior because it does not respect the projection.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions