Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
Stay organized with collections
Save and categorize content based on your preferences.
Creates a geometry.
Usage
Returns
ee.Geometry(geoJson, proj, geodesic, evenOdd)
Geometry
Argument
Type
Details
geoJson
Object
The 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.
proj
Projection, optional
An 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).
geodesic
Boolean, optional
Whether 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.
evenOdd
Boolean, optional
If 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003eCreates a geometry from a GeoJSON object, optionally specifying projection, geodesic handling, and polygon winding rule.\u003c/p\u003e\n"],["\u003cp\u003eAccepts GeoJSON objects or strings (which must be parsed into objects).\u003c/p\u003e\n"],["\u003cp\u003eEnables casting of computed geometry objects (like those in Feature properties) to the \u003ccode\u003eee.Geometry\u003c/code\u003e class for method access.\u003c/p\u003e\n"],["\u003cp\u003eSupports both JavaScript and Python environments within Google Earth Engine.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\nCreates a geometry.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------------------------|----------|\n| `ee.Geometry(geoJson, `*proj* `, `*geodesic* `, `*evenOdd*`)` | Geometry |\n\n| Argument | Type | Details |\n|------------|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `geoJson` | Object | The 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. |\n| `proj` | Projection, optional | An 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). |\n| `geodesic` | Boolean, optional | Whether 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. |\n| `evenOdd` | Boolean, optional | If 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. |\n\nExamples\n\nCode Editor (JavaScript) \n\n```javascript\n// A GeoJSON object for a triangular polygon.\nvar geojsonObject = {\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [\n -122.085,\n 37.423\n ],\n [\n -122.092,\n 37.424\n ],\n [\n -122.085,\n 37.418\n ],\n [\n -122.085,\n 37.423\n ]\n ]\n ]\n};\nprint('ee.Geometry accepts a GeoJSON object', ee.Geometry(geojsonObject));\n\n// GeoJSON strings need to be converted to an object.\nvar geojsonString = JSON.stringify(geojsonObject);\nprint('A GeoJSON string needs to be converted to an object',\n ee.Geometry(JSON.parse(geojsonString)));\n\n// Use ee.Geometry to cast computed geometry objects into the ee.Geometry\n// class to access their methods. In the following example an ee.Geometry\n// object is stored as a ee.Feature property. When it is retrieved with the\n// .get() function, a computed geometry object is returned. Cast the computed\n// object as a ee.Geometry to get the geometry's bounds, for instance.\nvar feature = ee.Feature(null, {geom: ee.Geometry(geojsonObject)});\nprint('Cast computed geometry objects to ee.Geometry class',\n ee.Geometry(feature.get('geom')).bounds());\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\nColab (Python) \n\n```python\nimport json\n\n# A GeoJSON object for a triangular polygon.\ngeojson_object = {\n 'type': 'Polygon',\n 'coordinates': [\n [\n [\n -122.085,\n 37.423\n ],\n [\n -122.092,\n 37.424\n ],\n [\n -122.085,\n 37.418\n ],\n [\n -122.085,\n 37.423\n ]\n ]\n ]\n}\nprint(\n 'ee.Geometry accepts a GeoJSON object:',\n ee.Geometry(geojson_object).getInfo()\n)\n\n# GeoJSON strings need to be converted to an object.\ngeojson_string = json.dumps(geojson_object)\nprint('A GeoJSON string needs to be converted to an object:',\n ee.Geometry(json.loads(geojson_string)).getInfo())\n\n# Use ee.Geometry to cast computed geometry objects into the ee.Geometry\n# class to access their methods. In the following example an ee.Geometry\n# object is stored as a ee.Feature property. When it is retrieved with the\n# .get() function, a computed geometry object is returned. Cast the computed\n# object as a ee.Geometry to get the geometry's bounds, for instance.\nfeature = ee.Feature(None, {'geom': ee.Geometry(geojson_object)})\nprint('Cast computed geometry objects to ee.Geometry class:',\n ee.Geometry(feature.get('geom')).bounds().getInfo())\n```"]]