Converts line(s) to polygon(s).
npm install @turf/line-to-polygonConverts (Multi)LineString(s) to Polygon(s).
* lines ([FeatureCollection][1] | [Feature][2]<([LineString][3] | [MultiLineString][4])>) Features to convert
* options [Object][5] Optional parameters (optional, default {})
* options.properties [Object][5] translates GeoJSON properties to Feature (optional, default {})
* options.autoComplete [boolean][6] auto complete linestrings (matches first & last coordinates) (optional, default true)
* options.orderCoords [boolean][6] sorts linestrings to place outer ring at the first position of the coordinates (optional, default true)
* options.mutate [boolean][6] mutate the original linestring using autoComplete (matches first & last coordinates) (optional, default false)
``javascript
var line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]);
var polygon = turf.lineToPolygon(line);
//addToMap
var addToMap = [polygon];
`
Returns [Feature][2]<([Polygon][7] | [MultiPolygon][8])> converted to Polygons
[1]: https://tools.ietf.org/html/rfc7946#section-3.3
[2]: https://tools.ietf.org/html/rfc7946#section-3.2
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.4
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.5
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.7
---
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/line-to-polygon
Or install the all-encompassing @turf/turf module that includes all modules as functions:
`sh``
$ npm install @turf/turf