公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
几何图形可视化和信息
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
直观呈现几何图形
如需直观呈现几何图形,请将其添加到地图中。例如:
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');
如需详细了解可视化,请参阅地图项和 FeatureCollection 可视化。
如需查看几何图形的相关信息,请输出该几何图形。如需以程序化方式访问这些信息,Earth Engine 提供了多种方法。例如,如需获取之前创建的多边形的相关信息,请使用以下命令:
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());
请注意,除非指定投影,否则几何图形的周长(或长度)以米为单位,面积以平方米为单位。默认情况下,计算会基于 WGS84 球体执行,计算结果以米或平方米为单位。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\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."]]