62 lines
2.0 KiB
Markdown
62 lines
2.0 KiB
Markdown
# @turf/polygonize
|
|
|
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
|
|
## polygonize
|
|
|
|
Polygonizes [(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.
|
|
|
|
### Parameters
|
|
|
|
* `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 file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
|
|
---
|
|
|
|
This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
|
|
|
|
### Installation
|
|
|
|
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
|
|
```
|