Turfjs / Turfjs/turf

turf.area() produces different results when redundant points are added

Open
#1,987 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

If polygon A shares a partial boundary of a larger polygon B, but is otherwise completely inside polygon B, turf.area() will give a different result for the dissolved result of A and B than B alone.

turf.area(turf.dissolve(A,B)) != turf.area(B)

This can be fixed by running turf.cleanCoords() on the dissolved polygon, at least in initial testing. I will put up an Observable notebook for testing soon.

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.

Research direction

Start by reproducing the area difference with the polygon setup described for turf.area() and turf.dissolve(), then compare the dissolved result with turf.cleanCoords(). The linked Observable notebook is not present, so establish a minimal reproducible case first; done means the dissolved result matches polygon B's area and the regression is covered.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.