lineToPolygon
Description
Converts (Multi)LineString(s) to Polygon(s).
Parameters
Name | Type | Description |
---|---|---|
lines | FeatureCollection | Feature<LineString | MultiLineString> | Features to convert |
options? | Object | Optional parameters (default {}) |
options.properties? | Object | translates GeoJSON properties to Feature (default {}) |
options.autoComplete? | boolean | auto complete linestrings (matches first & last coordinates) (default true) |
options.orderCoords? | boolean | sorts linestrings to place outer ring at the first position of the coordinates (default true) |
options.mutate? | boolean | mutate the original linestring using autoComplete (matches first & last coordinates) (default false) |
Returns
Feature<Polygon | MultiPolygon> converted to Polygons
Examples
var line = turf.lineString([
[125, -30],
[145, -30],
[145, -20],
[125, -20],
[125, -30],
]);
var polygon = turf.lineToPolygon(line);
Installation
$ npm install @turf/line-to-polygon
import { lineToPolygon } from "@turf/line-to-polygon";
const result = lineToPolygon(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineToPolygon(...);