公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
幾何視覺化和資訊
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
將幾何圖形視覺化
如要將幾何圖形顯示在地圖上,請將其加入地圖。例如:
程式碼編輯器 (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 提供多種方法。例如,如要取得先前建立的多邊形相關資訊,請使用:
程式碼編輯器 (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 橢圓球體上執行,結果會以公尺或平方公尺計算。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間: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."]]