Polygonizes a set of lines that represents edges in a planar graph.
npm install @turf/polygonizePolygonizes [(Multi)LineString(s)][1] into [Polygons][2].
Implementation of GEOSPolygonize function (geos::operation::polygonize::Polygonizer).
Polygonizes a set of lines that represents edges in a planar graph. Edges must be correctly
noded, i.e., they must only meet at their endpoints.
The implementation correctly handles:
* Dangles: edges which have one or both ends which are not incident on another edge endpoint.
* Cut Edges (bridges): edges that are connected at both ends but which do not form part of a polygon.
* geoJson ([FeatureCollection][3] | [Geometry][4] | [Feature][5]<([LineString][1] | [MultiLineString][6])>) Lines in order to polygonize
* Throws [Error][7] if geoJson is invalid.
Returns [FeatureCollection][3]<[Polygon][2]> Polygons created
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.6
[3]: https://tools.ietf.org/html/rfc7946#section-3.3
[4]: https://tools.ietf.org/html/rfc7946#section-3.1
[5]: https://tools.ietf.org/html/rfc7946#section-3.2
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.5
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
---
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 single module individually:
``sh`
$ npm install @turf/polygonize
Or install the all-encompassing @turf/turf module that includes all modules as functions:
`sh``
$ npm install @turf/turf