Turfjs / Turfjs/turf

turf-polygonize throws when otherwise valid geojson produces no valid polygons

Open
#2,473 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

  • version 6.5
  • can't share the data
  • no snippet.

Confirming this issue

Error: Each LinearRing of a Polygon must have 4 or more Positions.
    polygon index.js:227
    toPolygon EdgeRing.js:137
    getEnvelope EdgeRing.js:148
    findEdgeRingContaining EdgeRing.js:162
    findEdgeRingContaining EdgeRing.js:161
    polygonize index.js:41
    polygonize index.js:40

I haven't deeply investigated but I wouldn't be surprised if the incoming data is a bit defective.

The biggest problem is that an exception is thrown, which means no polygons at all are returned.

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 with the polygonize call path shown in index.js and EdgeRing.js, focusing on how a LinearRing with fewer than four positions is reached. Find or construct a reproducible GeoJSON case that produces no valid polygons, then verify that the operation no longer throws and that any valid polygons are still returned.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.