polygons
Description
Creates a Polygon FeatureCollection from an Array of Polygon coordinates.
Parameters
Name | Type | Description |
---|---|---|
coordinates | Array<Array<Array<Array<number>>>> | an array of Polygon coordinates |
properties? | Object | an Object of key-value pairs to add as properties (default {}) |
options? | Object | Optional Parameters (default {}) |
options.bbox? | Array<number> | Bounding Box Array [west, south, east, north] associated with the Feature |
options.id? | string | number | Identifier associated with the FeatureCollection |
Returns
FeatureCollection<Polygon> Polygon FeatureCollection
Examples
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
Installation
$ npm install @turf/helpers
import { polygons } from "@turf/helpers";
const result = polygons(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.polygons(...);