Skip to main content

polygon

Creates a Polygon geometry from an array of linear rings coordinates.

The first ring represents the exterior ring (shell), subsequent rings represent interior rings (holes). Each ring must be a closed line string with first and last positions identical and contain at least 3 positions. Empty polygons without any rings are allowed.

Type Parameters

  • P

Parameters

NameTypeDefaultDescription
pptsPosition[][]Polygon coordinates
options?objectOptional geometry options
options.id?number | stringOptional identifier to be assigned to the geometry instance.
options.properties?POptional data to be assigned to the geometry instance.
options.layout?'XY' | 'XYZ' | 'XYZM' | 'XYM''XYZM'Coordinate layout for interpreting GeoJSON coordinates.
Defines how to interpret the coordinates of input geometries. This does not force the dimension of the resulting geometries - the actual geometry dimension will be determined from the parsed data.
Use this to:
  • Trim unwanted Z or M ordinates from the input.
  • Treat the third ordinate as M instead of Z.

Returns

Polygon<P>

A new Polygon geometry

Throws

Examples