Skip to main content
Version: 7.3.0

lineToPolygon

描述

🌐 Description

将(多)线串转换为多边形。

🌐 Converts (Multi)LineString(s) to Polygon(s).

参数

🌐 Parameters

名称类型描述
linesFeatureCollection | Feature<LineString | MultiLineString>转换功能
options?Object可选参数 (默认 {})
options.properties?Object将 GeoJSON 属性转换为 Feature (默认 {})
options.autoComplete?boolean自动补齐线串(匹配第一个和最后一个坐标)(默认 true)
options.orderCoords?boolean对线串进行排序以将外环放置在坐标的第一个位置 (默认 true)
options.mutate?boolean使用自动补齐突变原始线串(匹配第一个和最后一个坐标)(默认 false)

返回

🌐 Returns

Feature<Polygon | MultiPolygon> 已转换为多边形

示例

🌐 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(...);