Skip to main content
Version: 7.0.0

polygons

Description

Creates a Polygon FeatureCollection from an Array of Polygon coordinates.

Parameters

NameTypeDescription
coordinatesArray<Array<Array<Array<number>>>>an array of Polygon coordinates
properties?Objectan Object of key-value pairs to add as properties (default {})
options?ObjectOptional Parameters (default {})
options.bbox?Array<number>Bounding Box Array [west, south, east, north] associated with the Feature
options.id?string | numberIdentifier associated with the FeatureCollection

Returns

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