Unexpected scale behavior for large areas that intersect WGS84 boundaries

Open
#1,059 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Domain
data

Research direction

Start with the transformScale entry point and the supplied reproduction, then inspect how bbox and bboxPolygon process its output near WGS84 boundaries. Reproduce the Europe example and compare other centers and scale factors; done means scaling is clipped to WGS84 without warping or unexpected boundary inversion.

Written by the indexing model from the issue text.

Description

@turf/transform-scale antimeridian

I tried to double the bounding box of Europe using turf and I get this weird result:

const Europe = /* See GeoJSON */;
const doubleEurope = transformScale(Europe,2);
const boundsOfDoubleEurope = bboxPolygon(bbox(transformScale(Europe, 2)));

The gist is quite self-explanatory.
The wrong result of transformScale clearly affects everything else. What I don't get is why it warps the resulting rectangle, extending its northern side much more than twice (or perhaps it is just inverting some sign).

Other similar odd results:

  • using a different center (e.g. 'ne', 'sw') results in other wrong figures
  • using scale factors higher than 2 results in even stranger figures.

I would expect the scaled figured to be clipped with WGS84 properly, and to never warp.

Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Turfjs/turf

All issues in Turfjs/turf

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.