Turf.jsMisc

turf.unkinkPolygon

What is turf.unkinkPolygon?

turf.unkinkPolygon takes a self-intersecting Polygon or MultiPolygon and returns a FeatureCollection<Polygon> where each feature is a valid, simple polygon formed by splitting the original at its self-intersection points.

JavaScript
turf.unkinkPolygon(polygon) → FeatureCollection<Polygon>

When would you use turf.unkinkPolygon?

Use turf.unkinkPolygon after turf.kinks flags a self-intersecting polygon that you cannot simply reject — for example, when cleaning up bad imported data or fixing user drawings that accidentally crossed themselves. After unkinking, each output polygon is safe to use with turf.area, turf.union, and turf.intersect.

In Node.js ETL, combining turf.kinks + turf.unkinkPolygon is a common pipeline step for normalising polygons coming from legacy shapefiles, hand-digitised KML, or imprecise upstream processing.

Code
undefined

FAQs

Does it preserve total area?

Not exactly. Self-intersections mean the original polygon's notional "area" is ambiguous — unkinking produces a set of simple polygons whose combined area reflects the actual enclosed regions.

How do I install just unkinkPolygon?

npm install @turf/unkink-polygon. It depends on @turf/helpers, @turf/boolean-point-in-polygon, @turf/area, and rbush.

What about MultiPolygon inputs?

Supported — each component polygon is checked and unkinked independently, and all resulting simple polygons are returned in the FeatureCollection.

Should I unkink before or after other ops?

Before. Self-intersecting polygons break turf.union, turf.intersect, and turf.area. Always validate with turf.kinks and clean with turf.unkinkPolygon at the start of a pipeline.