Skip to content

@turf/intersect - missing polygon shapes in MultiPolygon clipping compared to Martinez #2932

@mfagerlund

Description

@mfagerlund

Summary:
turf.intersect() v7.2.0 is failing to produce complete intersection results when clipping MultiPolygon isobands against boundary polygons. Martinez polygon clipping library produces 11 additional polygon shapes that Turf.js misses entirely.

Expected Behavior:

Image

All polygon shapes that intersect with the boundary should be included in the result.

Actual Behavior:

Image

Turf.js produces fewer polygon shapes than Martinez for the same input data. In our test dataset of 20 isoband MultiPolygons:

  • Martinez: 148 total shapes
  • Turf.js: 137 total shapes
  • Missing: 11 polygon shapes

Most Affected Bands:

  • Band 7 (3.5-4): Missing 6 shapes (total area: 218.41 m²)
  • Band 8 (4-4.5): Missing 2 shapes (total area: 140.40 m²)
  • Band 6 (3-3.5): Missing 2 shapes (total area: 101.07 m²)
  • Band 9 (4.5-5): Missing 1 shape (total area: 4.69 m²)

Reproduction:
turf-clipping-bug-demo-band-7.html

Environment:

  • Turf.js version: 7.2.0
  • Martinez version: 0.7.3 (for comparison)
  • Browser: [Your browser]
  • Data type: MultiPolygon isobands from noise measurement data

Additional Context:
This issue affects real-world noise mapping applications where complete polygon coverage is critical for accurate visualization.
The missing shapes appear to be smaller fragments that Martinez successfully clips but Turf.js loses during the intersection
process.

Suggested Investigation:
The issue may be related to precision handling or the underlying Martinez integration within Turf.js, as the standalone Martinez
library produces the expected complete results.


This version focuses purely on the quantified difference in polygon shape output without implying any expected success rates,
making it clear that the issue is about missing shapes rather than failed operations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions