Turfjs / Turfjs/turf

@turf/isobands generates wrong inner circle

Open
#2,999 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm trying to use isobands, but sometime got incorrect result.
Example:
Cyan (985) polygon expected to be one polygon with hole, but it generated two polygons without holes.
Image
Image

Grid points:
Image
Code for reproduce:

  fetch("../point.json")
      .then((res) => res.text())
      .then((text) => {
        const pointGrid = JSON.parse(text);
        const breaks = [
          965, 970, 975, 980, 985, 990, 995, 1000, 1005, 1010, 1015, 1020, 1025,
          1030, 1035, 1040,
        ];
        let result = turf.isobands(pointGrid, breaks, {
          zProperty: "value",
        });
        console.log(result);
      });

If manualy replace two polygons with one, it turns out well.

 result.features[4].geometry.coordinates = [[result.features[4].geometry.coordinates[1][0], result.features[4].geometry.coordinates[0][0]]]    
Image

My raw data attached
point.json
isobands.json

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 at the turf.isobands entry point and reproduce the report with the attached point.json and breaks array; compare the generated isobands.json with the screenshots and stated expected geometry. Trace how the 985 band is assembled, and consider the issue done when that band is one polygon with an inner hole without manual coordinate replacement and the other bands remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data-visualization
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.