Earth Engine 即將推出
非商業用途的配額級別 ,以便保護共用運算資源,並確保所有使用者都能享有穩固效能。所有非商業用途的專案都必須在
2026 年 4 月 27 日 前選取配額級別,否則屆時會預設為「社群」級別。在
2026 年 4 月 27 日 ,所有專案 (無論選取級別的日期為何) 的級別配額都會生效。
瞭解詳情 。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
提供意見
ee.Geometry.MultiPolygon.union
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
傳回兩個幾何圖形的聯集。
用量 傳回 MultiPolygon. union (right, maxError , proj )幾何圖形
引數 類型 詳細資料 這個:left 幾何圖形 做為運算左運算元的幾何圖形。 right幾何圖形 用做運算右運算元的幾何圖形。 maxErrorErrorMargin,預設值:null 執行任何必要重投影時可容許的最大誤差量。 proj投影,預設值:null 執行作業的投影。如未指定,系統會以球面座標系統執行作業,而球面上的線性距離會以公尺為單位。
範例
程式碼編輯器 (JavaScript)
// Define a MultiPolygon object.
var multiPolygon = ee . Geometry . MultiPolygon (
[[[[ - 122.092 , 37.424 ],
[ - 122.086 , 37.418 ],
[ - 122.079 , 37.425 ],
[ - 122.085 , 37.423 ]]],
[[[ - 122.081 , 37.417 ],
[ - 122.086 , 37.421 ],
[ - 122.089 , 37.416 ]]]]);
// Define other inputs.
var inputGeom = ee . Geometry . BBox ( - 122.085 , 37.415 , - 122.075 , 37.425 );
// Apply the union method to the MultiPolygon object.
var multiPolygonUnion = multiPolygon . union ({ 'right' : inputGeom , 'maxError' : 1 });
// Print the result to the console.
print ( 'multiPolygon.union(...) =' , multiPolygonUnion );
// Display relevant geometries on the map.
Map . setCenter ( - 122.085 , 37.422 , 15 );
Map . addLayer ( multiPolygon ,
{ 'color' : 'black' },
'Geometry [black]: multiPolygon' );
Map . addLayer ( inputGeom ,
{ 'color' : 'blue' },
'Parameter [blue]: inputGeom' );
Map . addLayer ( multiPolygonUnion ,
{ 'color' : 'red' },
'Result [red]: multiPolygon.union' );
Python 設定
請參閱
Python 環境 頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。
import ee
import geemap.core as geemap
Colab (Python)
# Define a MultiPolygon object.
multipolygon = ee . Geometry . MultiPolygon ([
[[
[ - 122.092 , 37.424 ],
[ - 122.086 , 37.418 ],
[ - 122.079 , 37.425 ],
[ - 122.085 , 37.423 ],
]],
[[[ - 122.081 , 37.417 ], [ - 122.086 , 37.421 ], [ - 122.089 , 37.416 ]]],
])
# Define other inputs.
input_geom = ee . Geometry . BBox ( - 122.085 , 37.415 , - 122.075 , 37.425 )
# Apply the union method to the MultiPolygon object.
multipolygon_union = multipolygon . union ( right = input_geom , maxError = 1 )
# Print the result.
display ( 'multipolygon.union(...) =' , multipolygon_union )
# Display relevant geometries on the map.
m = geemap . Map ()
m . set_center ( - 122.085 , 37.422 , 15 )
m . add_layer (
multipolygon , { 'color' : 'black' }, 'Geometry [black]: multipolygon'
)
m . add_layer ( input_geom , { 'color' : 'blue' }, 'Parameter [blue]: input_geom' )
m . add_layer (
multipolygon_union , { 'color' : 'red' }, 'Result [red]: multipolygon.union'
)
m
提供意見
除非另有註明,否則本頁面中的內容是採用創用 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 (世界標準時間)。"],[],["The `union` method combines two geometries, a `left` and a `right`, into a single geometry representing their union. Optional parameters include `maxError`, which sets the tolerated error during reprojection, and `proj`, the operation's projection. The method returns a new geometry. Example shows creating a `MultiPolygon` object, a `BBox` geometry, and combining them with a `union` call, the result then being printed and displayed on a map.\n"]]