Skip to content

描述 ​

从多边形坐标数组创建 Polygon FeatureCollection。

参数 ​

名称类型描述
coordinatesUNCERTAIN
properties?GeoJsonProperties作为属性添加的键值对对象 (默认 {})
options?Object可选参数 (默认 {})
options.bbox?BBox与 FeatureCollection 关联的边界框数组 [西, 南, 东, 北]
options.id?Id与 FeatureCollection 关联的标识符

返回值 ​

FeatureCollection<Polygon, GeoJsonProperties> Polygon FeatureCollection

示例 ​

javascript
var polygons = turf.polygons([
  [
    [
      [-5, 52],
      [-4, 56],
      [-2, 51],
      [-7, 54],
      [-5, 52],
    ],
  ],
  [
    [
      [-15, 42],
      [-14, 46],
      [-12, 41],
      [-17, 44],
      [-15, 42],
    ],
  ],
]);

//=polygons

安装 ​

javascript
$ npm install @turf/helpers

import { polygons } from "@turf/helpers";
const result = polygons(...);
javascript
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.polygons(...);