ee.Geometry

Creates a geometry.
UsageReturns
ee.Geometry(geoJson, proj, geodesic, evenOdd)Geometry
ArgumentTypeDetails
geoJsonObjectThe GeoJSON object describing the geometry or a ComputedObject to be reinterpreted as a Geometry. Supports CRS specifications as per the GeoJSON spec, but only allows named

(rather than "linked" CRSs). If this includes a 'geodesic' field, and opt_geodesic is not specified, it will be used as opt_geodesic.

projProjection, optionalAn optional projection specification, either as a CRS ID code or as a WKT string. If specified, overrides any CRS found in the geoJson parameter. If unspecified and the geoJson does not declare a CRS, defaults to "EPSG:4326" (x=longitude, y=latitude).
geodesicBoolean, optionalWhether line segments should be interpreted as spherical geodesics. If false, indicates that line segments should be interpreted as planar lines in the specified CRS. If absent, defaults to true if the CRS is geographic (including the default EPSG:4326), or to false if the CRS is projected.
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)

// A GeoJSON object for a triangular polygon.
var geojsonObject = {
  "type": "Polygon",
  "coordinates": [
    [
      [
        -122.085,
        37.423
      ],
      [
        -122.092,
        37.424
      ],
      [
        -122.085,
        37.418
      ],
      [
        -122.085,
        37.423
      ]
    ]
  ]
};
print('ee.Geometry accepts a GeoJSON object', ee.Geometry(geojsonObject));

// GeoJSON strings need to be converted to an object.
var geojsonString = JSON.stringify(geojsonObject);
print('A GeoJSON string needs to be converted to an object',
      ee.Geometry(JSON.parse(geojsonString)));

// Use ee.Geometry to cast computed geometry objects into the ee.Geometry
// class to access their methods. In the following example an ee.Geometry
// object is stored as a ee.Feature property. When it is retrieved with the
// .get() function, a computed geometry object is returned. Cast the computed
// object as a ee.Geometry to get the geometry's bounds, for instance.
var feature = ee.Feature(null, {geom: ee.Geometry(geojsonObject)});
print('Cast computed geometry objects to ee.Geometry class',
      ee.Geometry(feature.get('geom')).bounds());