
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
@turf/unkink-polygon
Advanced tools
@turf/unkink-polygon is a module in the Turf.js library that is used to convert polygons with self-intersections (kinks) into simple polygons without self-intersections. This is useful for ensuring that polygon geometries are valid and can be used in various geospatial analyses.
Unkink Polygon
This feature takes a polygon with self-intersections and returns a FeatureCollection of polygons without self-intersections. The code sample demonstrates how to use the `unkinkPolygon` function to process a polygon and output the resulting simple polygons.
const turf = require('@turf/turf');
const unkinkPolygon = require('@turf/unkink-polygon');
const polygon = turf.polygon([[
[-12.034835, 8.901183],
[-12.060413, 8.899826],
[-12.03638, 8.873199],
[-12.059383, 8.871418],
[-12.034835, 8.901183]
]]);
const result = unkinkPolygon(polygon);
console.log(result);
JSTS (JavaScript Topology Suite) is a JavaScript library for processing and analyzing planar geometric objects. It provides a wide range of geometric operations, including the ability to handle self-intersecting polygons. Compared to @turf/unkink-polygon, JSTS offers more comprehensive geometric processing capabilities but may be more complex to use for simple tasks.
Martinez Polygon Clipping is a library for performing boolean operations on polygons, such as union, intersection, difference, and xor. It can handle self-intersecting polygons and is known for its performance. While it provides similar functionality to @turf/unkink-polygon in terms of handling complex polygons, it focuses more on boolean operations rather than just unkinking polygons.
Takes a kinked polygon and returns a feature collection of polygons that have no kinks. Uses simplepolygon internally.
Parameters
geojson
(FeatureCollection | Feature<(Polygon | MultiPolygon)>) GeoJSON Polygon or MultiPolygonExamples
var poly = turf.polygon([[[0, 0], [2, 0], [0, 2], [2, 2], [0, 0]]]);
var result = turf.unkinkPolygon(poly);
//addToMap
var addToMap = [poly, result]
Returns FeatureCollection<Polygon> Unkinked polygons
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/unkink-polygon
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf unkink-polygon module
We found that @turf/unkink-polygon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.