公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取。如未在 2025 年 9 月 26 日前完成驗證,存取權可能會暫停。
ee.Geometry.Polygon
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
建構描述多邊形的 ee.Geometry。
為方便起見,如果所有引數都是數字,可以使用 varargs。這項功能可讓您使用偶數個引數 (例如 ee.Geometry.Polygon(aLng, aLat, bLng, bLat, ..., aLng, aLat)),透過單一 LinearRing 建立測地線 EPSG:4326 多邊形。
| 用量 | 傳回 |
|---|
ee.Geometry.Polygon(coords, proj, geodesic, maxError, evenOdd) | Geometry.Polygon |
| 引數 | 類型 | 詳細資料 |
|---|
coords | List<Geometry>|List<List<List<Number>>>|List<Number> | 定義多邊形邊界的環清單。可以是 GeoJSON「多邊形」格式的座標清單、描述 LinearRing 的 ee.Geometry 物件清單,或是定義單一多邊形邊界的數字清單。 |
proj | 投影 (選用) | 這個幾何圖形的投影。預設值為輸入內容的投影,其中數字假設為 EPSG:4326。 |
geodesic | 布林值 (選填) | 如果為 false,投影畫面中的邊緣會是直線。如果是 true,邊緣會彎曲,以遵循地球表面的最短路徑。預設值為輸入內容的測地線狀態,如果輸入內容為數字,則為 true。 |
maxError | ErrorMargin (選用) | 輸入幾何圖形必須重新投影至明確要求的結果投影或測地狀態時,可能發生的最大誤差。 |
evenOdd | 布林值 (選填) | 如果為 true,多邊形內部會依據偶數/奇數規則判斷,也就是說,如果某個點要抵達無限遠的點,必須穿過奇數個邊緣,該點就會位於多邊形內部。否則,多邊形會使用左側內部規則,也就是沿著頂點以指定順序移動時,內部位於外殼邊緣的左側。如未指定,則預設為 true。 |
範例
程式碼編輯器 (JavaScript)
// Construct a polygon from a list of GeoJSON 'Polygon' formatted coordinates.
var polygonGeoJSON = ee.Geometry.Polygon(
[
[ // exterior ring
[100.0, 0.0],
[103.0, 0.0],
[103.0, 3.0],
[100.0, 3.0],
[100.0, 0.0] // matching the first vertex is optional
],
[ // interior ring
[101.0, 1.0],
[102.0, 2.0],
[102.0, 1.0]
]
]
);
Map.addLayer(polygonGeoJSON, {}, 'polygonGeoJSON');
// Construct a polygon from an ee.Geometry.LinearRing.
var polygonLinearRing = ee.Geometry.Polygon(
[
ee.Geometry.LinearRing(
[
[105.0, 0.0],
[108.0, 0.0],
[108.0, 3.0]
]
)
]
);
Map.addLayer(polygonLinearRing, {}, 'polygonLinearRing');
// Construct a polygon from a list of x,y coordinate pairs defining a boundary.
var polygonCoordList = ee.Geometry.Polygon(
[110.0, 0.0, 113.0, 0.0, 110.0, 3.0]
);
Map.addLayer(polygonCoordList, {}, 'polygonCoordList');
Map.centerObject(polygonLinearRing);
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-10-24 (世界標準時間)。
[null,null,["上次更新時間:2025-10-24 (世界標準時間)。"],[],["This describes the `ee.Geometry.Polygon` constructor, which creates a polygon geometry. Key actions include defining polygon boundaries using a list of rings (in GeoJSON format, as `ee.Geometry.LinearRing` objects, or coordinate pairs). The constructor accepts optional parameters: `proj` (projection), `geodesic` (edge curvature), `maxError` (reprojection error), and `evenOdd` (interior rule). Default values are provided if the parameters are omitted, and the input arguments dictate them.\n"]]