Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
Geometry Visualization and Information
Stay organized with collections
Save and categorize content based on your preferences.
Visualizing geometries
To visualize a geometry, add it to the map. For example:
Code Editor (JavaScript)
// Create a geodesic polygon.
var polygon = ee.Geometry.Polygon([
[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]
]);
// Create a planar polygon.
var planarPolygon = ee.Geometry(polygon, null, false);
// Display the polygons by adding them to the map.
Map.centerObject(polygon);
Map.addLayer(polygon, {color: 'FF0000'}, 'geodesic polygon');
Map.addLayer(planarPolygon, {color: '000000'}, 'planar polygon');
For more on visualizing, see Feature and
FeatureCollection Visualization.
To view information about a geometry, print it. To access the information
programmatically, Earth Engine provides several methods. For example, to get information
about the polygon created previously, use:
Code Editor (JavaScript)
print('Polygon printout: ', polygon);
// Print polygon area in square kilometers.
print('Polygon area: ', polygon.area().divide(1000 * 1000));
// Print polygon perimeter length in kilometers.
print('Polygon perimeter: ', polygon.perimeter().divide(1000));
// Print the geometry as a GeoJSON string.
print('Polygon GeoJSON: ', polygon.toGeoJSONString());
// Print the GeoJSON 'type'.
print('Geometry type: ', polygon.type());
// Print the coordinates as lists.
print('Polygon coordinates: ', polygon.coordinates());
// Print whether the geometry is geodesic.
print('Geodesic? ', polygon.geodesic());
Observe that the perimeter (or length) of a geometry is returned in meters and the
area is returned in square meters unless a projection is specified. By default, the
computation is performed on the WGS84 spheroid and the result is computed in meters or
square meters.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["\u003cp\u003eGeometries can be visualized on the map by adding them as layers with styling options like color.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve information about a geometry such as area, perimeter, type, and coordinates programmatically using methods like \u003ccode\u003earea()\u003c/code\u003e, \u003ccode\u003eperimeter()\u003c/code\u003e, \u003ccode\u003etype()\u003c/code\u003e, and \u003ccode\u003ecoordinates()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eGeometry calculations are performed on the WGS84 spheroid by default, with perimeter returned in meters and area in square meters.\u003c/p\u003e\n"],["\u003cp\u003eTo visualize geometries on the Earth Engine map, you can use \u003ccode\u003eMap.addLayer()\u003c/code\u003e with styling options.\u003c/p\u003e\n"],["\u003cp\u003eFor programmatic access to geometry data, Earth Engine provides methods for retrieving information like type, area, perimeter, and coordinates.\u003c/p\u003e\n"]]],["Geometries are visualized by adding them to the map using `Map.addLayer()`. Information about a geometry can be accessed by printing it. Specific details like area, perimeter, GeoJSON representation, type, coordinates, and geodesic properties are obtained via methods like `.area()`, `.perimeter()`, `.toGeoJSONString()`, `.type()`, `.coordinates()`, and `.geodesic()`. By default, perimeter and area are returned in meters and square meters, respectively, based on the WGS84 spheroid.\n"],null,["# Geometry Visualization and Information\n\nVisualizing geometries\n----------------------\n\nTo visualize a geometry, add it to the map. For example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create a geodesic polygon.\nvar polygon = ee.Geometry.Polygon([\n [[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]\n]);\n\n// Create a planar polygon.\nvar planarPolygon = ee.Geometry(polygon, null, false);\n\n// Display the polygons by adding them to the map.\nMap.centerObject(polygon);\nMap.addLayer(polygon, {color: 'FF0000'}, 'geodesic polygon');\nMap.addLayer(planarPolygon, {color: '000000'}, 'planar polygon');\n```\n\nFor more on visualizing, see [Feature and\nFeatureCollection Visualization](/earth-engine/guides/feature_collections_visualizing).\n\nGeometry information and metadata\n---------------------------------\n\nTo view information about a geometry, print it. To access the information\nprogrammatically, Earth Engine provides several methods. For example, to get information\nabout the polygon created previously, use:\n\n### Code Editor (JavaScript)\n\n```javascript\nprint('Polygon printout: ', polygon);\n\n// Print polygon area in square kilometers.\nprint('Polygon area: ', polygon.area().divide(1000 * 1000));\n\n// Print polygon perimeter length in kilometers.\nprint('Polygon perimeter: ', polygon.perimeter().divide(1000));\n\n// Print the geometry as a GeoJSON string.\nprint('Polygon GeoJSON: ', polygon.toGeoJSONString());\n\n// Print the GeoJSON 'type'.\nprint('Geometry type: ', polygon.type());\n\n// Print the coordinates as lists.\nprint('Polygon coordinates: ', polygon.coordinates());\n\n// Print whether the geometry is geodesic.\nprint('Geodesic? ', polygon.geodesic());\n```\n\nObserve that the perimeter (or length) of a geometry is returned in meters and the\narea is returned in square meters unless a projection is specified. By default, the\ncomputation is performed on the WGS84 spheroid and the result is computed in meters or\nsquare meters."]]