Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.Geometry.Polygon

  • Theee.Geometry.Polygon function constructs a polygon geometry in Earth Engine.

  • Polygons can be defined using a list of coordinates in various formats including GeoJSON 'Polygon',ee.Geometry.LinearRing objects, or a simple list of numbers.

  • Optional arguments likeproj,geodesic,maxError, andevenOdd control the polygon's projection, edge curvature, error handling, and interior determination rule.

  • Varargs can be used for convenience with all number arguments to create a single-ring geodesic EPSG:4326 polygon.

Constructs an ee.Geometry describing a polygon.

For convenience, varargs may be used when all arguments are numbers. This allows creating geodesic EPSG:4326 Polygons with a single LinearRing given an even number of arguments, e.g. ee.Geometry.Polygon(aLng, aLat, bLng, bLat, ..., aLng, aLat).

UsageReturns
ee.Geometry.Polygon(coords,proj,geodesic,maxError,evenOdd)Geometry.Polygon
ArgumentTypeDetails
coordsList<Geometry>|List<List<List<Number>>>|List<Number>A list of rings defining the boundaries of the polygon. May be a list of coordinates in the GeoJSON 'Polygon' format, a list of ee.Geometry objects describing a LinearRing, or a list of numbers defining a single polygon boundary.
projProjection, optionalThe projection of this geometry. The default is the projection of the inputs, where Numbers are assumed to be EPSG:4326.
geodesicBoolean, optionalIf false, edges are straight in the projection. If true, edges are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
maxErrorErrorMargin, optionalMax error when input geometry must be reprojected to an explicitly requested result projection or geodesic state.
evenOddBoolean, optionalIf true, polygon interiors will be determined by the even/odd rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left- inside rule, where interiors are on the left side of the shell's edges when walking the vertices in the given order. If unspecified, defaults to true.

Examples

Code Editor (JavaScript)

// Construct a polygon from a list of GeoJSON 'Polygon' formatted coordinates.varpolygonGeoJSON=ee.Geometry.Polygon([[// exterior ring[100.0,0.0],[103.0,0.0],[103.0,3.0],[100.0,3.0],[100.0,0.0]// matching the first vertex is optional],[// interior ring[101.0,1.0],[102.0,2.0],[102.0,1.0]]]);Map.addLayer(polygonGeoJSON,{},'polygonGeoJSON');// Construct a polygon from an ee.Geometry.LinearRing.varpolygonLinearRing=ee.Geometry.Polygon([ee.Geometry.LinearRing([[105.0,0.0],[108.0,0.0],[108.0,3.0]])]);Map.addLayer(polygonLinearRing,{},'polygonLinearRing');// Construct a polygon from a list of x,y coordinate pairs defining a boundary.varpolygonCoordList=ee.Geometry.Polygon([110.0,0.0,113.0,0.0,110.0,3.0]);Map.addLayer(polygonCoordList,{},'polygonCoordList');Map.centerObject(polygonLinearRing);

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-08 UTC.