公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.Geometry.Rectangle
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
建構描述矩形多邊形的 ee.Geometry。
為方便起見,如果所有引數都是數字,可以使用 varargs。這項功能可讓您使用四個座標建立 EPSG:4326 多邊形,例如 ee.Geometry.Rectangle(minLng, minLat, maxLng, maxLat)。
用量 | 傳回 |
---|
ee.Geometry.Rectangle(coords, proj, geodesic, evenOdd) | Geometry.Rectangle |
引數 | 類型 | 詳細資料 |
---|
coords | List<Geometry>|List<List<Number>>|List<Number> | 矩形的最小和最大角,以 GeoJSON「Point」座標格式的兩個點清單、描述點的兩個 ee.Geometry 物件清單,或依 xMin、yMin、xMax、yMax 順序排列的四個數字清單表示。 |
proj | 投影 (選用) | 這個幾何圖形的投影。如未指定,則預設為輸入 ee.Geometry 的投影,如果沒有 ee.Geometry 輸入,則為 EPSG:4326。 |
geodesic | 布林值 (選填) | 如果為 false,投影畫面中的邊緣會是直線。如果是 true,邊緣會彎曲,以遵循地球表面的最短路徑。預設值為輸入內容的測地線狀態,如果輸入內容為數字,則為 true。 |
evenOdd | 布林值 (選填) | 如果為 true,多邊形內部會依據偶數/奇數規則判斷,也就是說,如果某個點要抵達無限遠的點,必須穿過奇數個邊緣,該點就會位於多邊形內部。否則,多邊形會使用左側內部規則,也就是沿著頂點以指定順序移動時,內部位於外殼邊緣的左側。如未指定,則預設為 true。 |
範例
程式碼編輯器 (JavaScript)
// Coordinates for the bounds of a rectangle.
var xMin = -122.09;
var yMin = 37.42;
var xMax = -122.08;
var yMax = 37.43;
// Construct a rectangle from a list of GeoJSON 'point' formatted coordinates.
var rectangleGeoJSON = ee.Geometry.Rectangle(
[
[xMin, yMin],
[xMax, yMax] // max x and y
]
);
Map.addLayer(rectangleGeoJSON, {}, 'rectangleGeoJSON');
// Construct a rectangle from a list of ee.Geometry.Point objects.
var rectanglePoint = ee.Geometry.Rectangle(
[
ee.Geometry.Point(xMin, yMin), // min x and y
ee.Geometry.Point(xMax, yMax) // max x and y
]
);
Map.addLayer(rectanglePoint, {}, 'rectanglePoint');
// Construct a rectangle from a list of bounding coordinates.
var rectangleBounds = ee.Geometry.Rectangle(
[xMin, yMin, xMax, yMax]
);
Map.addLayer(rectangleBounds, {}, 'rectangleBounds');
Map.setCenter(-122.085, 37.422, 15);
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eDefines a rectangular polygon geometry in Earth Engine.\u003c/p\u003e\n"],["\u003cp\u003eAccepts coordinates as GeoJSON points, Earth Engine points, or bounding numbers.\u003c/p\u003e\n"],["\u003cp\u003eAllows specifying projection, geodesic nature, and polygon interior rules.\u003c/p\u003e\n"],["\u003cp\u003eProvides a convenient way to create EPSG:4326 polygons with four coordinates directly.\u003c/p\u003e\n"]]],[],null,["# ee.Geometry.Rectangle\n\n\u003cbr /\u003e\n\nConstructs an ee.Geometry describing a rectangular polygon.\n\n\u003cbr /\u003e\n\nFor convenience, varargs may be used when all arguments are numbers. This allows creating EPSG:4326 Polygons given exactly four coordinates, e.g. ee.Geometry.Rectangle(minLng, minLat, maxLng, maxLat).\n\n| Usage | Returns |\n|------------------------------------------------------------------------|--------------------|\n| `ee.Geometry.Rectangle(coords, `*proj* `, `*geodesic* `, `*evenOdd*`)` | Geometry.Rectangle |\n\n| Argument | Type | Details |\n|------------|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `coords` | List\\\u003cGeometry\\\u003e\\|List\\\u003cList\\\u003cNumber\\\u003e\\\u003e\\|List\\\u003cNumber\\\u003e | The minimum and maximum corners of the rectangle, as a list of two points each in the format of GeoJSON 'Point' coordinates, or a list of two ee.Geometry objects describing a point, or a list of four numbers in the order xMin, yMin, xMax, yMax. |\n| `proj` | Projection, optional | The projection of this geometry. If unspecified, the default is the projection of the input ee.Geometry, or EPSG:4326 if there are no ee.Geometry inputs. |\n| `geodesic` | Boolean, optional | If false, edges are straight in the projection. If true, edges are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers. |\n| `evenOdd` | Boolean, optional | If true, polygon interiors will be determined by the even/odd rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left- inside rule, where interiors are on the left side of the shell's edges when walking the vertices in the given order. If unspecified, defaults to true. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Coordinates for the bounds of a rectangle.\nvar xMin = -122.09;\nvar yMin = 37.42;\nvar xMax = -122.08;\nvar yMax = 37.43;\n\n// Construct a rectangle from a list of GeoJSON 'point' formatted coordinates.\nvar rectangleGeoJSON = ee.Geometry.Rectangle(\n [\n [xMin, yMin],\n [xMax, yMax] // max x and y\n ]\n);\nMap.addLayer(rectangleGeoJSON, {}, 'rectangleGeoJSON');\n\n// Construct a rectangle from a list of ee.Geometry.Point objects.\nvar rectanglePoint = ee.Geometry.Rectangle(\n [\n ee.Geometry.Point(xMin, yMin), // min x and y\n ee.Geometry.Point(xMax, yMax) // max x and y\n ]\n);\nMap.addLayer(rectanglePoint, {}, 'rectanglePoint');\n\n// Construct a rectangle from a list of bounding coordinates.\nvar rectangleBounds = ee.Geometry.Rectangle(\n [xMin, yMin, xMax, yMax]\n);\nMap.addLayer(rectangleBounds, {}, 'rectangleBounds');\n\nMap.setCenter(-122.085, 37.422, 15);\n```"]]