Skip to main content
Version: 7.3.0

lineToPolygon

描述

🌐 Description

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

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

参数

🌐 Parameters

名称类型描述
FeatureCollection | Feature<LineString | MultiLineString>要转换的要素
options?对象可选参数 (默认 {})
options.properties?对象将 GeoJSON 属性转换为 Feature (默认 {})
options.autoComplete?布尔自动补齐折线(匹配首尾坐标)(默认 true)
options.orderCoords?布尔对线串进行排序,以将外环放在坐标的第一个位置 (默认 true)
options.mutate?布尔使用自动补全(匹配第一个和最后一个坐标)修改原始线串 (默认 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(...);