公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取。如未在 2025 年 9 月 26 日前完成驗證,存取權可能會暫停。
ee.Geometry
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
建立幾何圖形。
用量 | 傳回 |
---|
ee.Geometry(geoJson, proj, geodesic, evenOdd) | 幾何圖形 |
引數 | 類型 | 詳細資料 |
---|
geoJson | 物件 | 描述幾何的 GeoJSON 物件,或要重新解讀為 Geometry 的 ComputedObject。支援 GeoJSON 規格的 CRS 規格,但只允許具名 (而非「連結」的 CRS)。如果這包含「測地線」欄位,且未指定 opt_geodesic,則會將其做為 opt_geodesic 使用。 |
proj | 投影 (選用) | 投影規格 (選用),可以是 CRS ID 程式碼或 WKT 字串。如果指定,則會覆寫 geoJson 參數中找到的任何 CRS。如果未指定,且 geoJson 未宣告 CRS,則預設為「EPSG:4326」(x=經度,y=緯度)。 |
geodesic | 布林值 (選填) | 是否應將線段解讀為球形測地線。如果為 false,表示線段應解讀為指定 CRS 中的平面線。如果未提供,則預設值為 true (如果 CRS 為地理座標系統,包括預設的 EPSG:4326),或 false (如果 CRS 為投影座標系統)。 |
evenOdd | 布林值 (選填) | 如果為 true,多邊形內部會依據偶數/奇數規則判斷,也就是說,如果某個點要抵達無限遠的點,必須穿過奇數個邊緣,該點就會位於多邊形內部。否則,多邊形會使用左側內部規則,也就是沿著頂點以指定順序移動時,內部位於外殼邊緣的左側。如未指定,則預設為 true。 |
範例
程式碼編輯器 (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());
Python 設定
請參閱
Python 環境頁面,瞭解 Python API 和如何使用 geemap
進行互動式開發。
import ee
import geemap.core as geemap
Colab (Python)
import json
# A GeoJSON object for a triangular polygon.
geojson_object = {
'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(geojson_object).getInfo()
)
# GeoJSON strings need to be converted to an object.
geojson_string = json.dumps(geojson_object)
print('A GeoJSON string needs to be converted to an object:',
ee.Geometry(json.loads(geojson_string)).getInfo())
# 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.
feature = ee.Feature(None, {'geom': ee.Geometry(geojson_object)})
print('Cast computed geometry objects to ee.Geometry class:',
ee.Geometry(feature.get('geom')).bounds().getInfo())
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],[]]