Skip to main content
Version: Next

polygons

Description

Creates a Polygon FeatureCollection from an Array of Polygon coordinates.

Parameters

NameTypeDescription
coordinatesUNCERTAIN
properties?GeoJsonPropertiesan Object of key-value pairs to add as properties (default {})
options?ObjectOptional Parameters (default {})
options.bbox?BBoxBounding Box Array [west, south, east, north] associated with the Feature
options.id?IdIdentifier associated with the FeatureCollection

Returns

FeatureCollection<Polygon, GeoJsonProperties> 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(...);