ee.Geometry.Rectangle.simplify

將幾何圖形簡化至指定誤差範圍內。請注意,除非明確將 maxError 指定為空值,否則這項設定不會遵守此演算法消費者要求誤差範圍。

這會覆寫 Earth Engine 傳播誤差範圍的預設政策,因此無論輸出內容要求的幾何準確度為何,系統都會以這個演算法引數中指定的誤差範圍要求輸入內容。這樣一來,算繪的向量地圖在所有縮放等級都會一致算繪,但在較低的縮放等級 (即縮小) 時,幾何圖形不會簡化,可能會影響效能。

用量傳回
Rectangle.simplify(maxError, proj)幾何圖形
引數類型詳細資料
這個:geometry幾何圖形要簡化的幾何圖形。
maxErrorErrorMargin結果與輸入內容之間的最大誤差量。
proj投影,預設值:null如果指定,結果會以這個投影方式呈現。否則會與輸入內容的投影相同。如果誤差範圍是以預測單位表示,系統會將誤差範圍解讀為預測單位。

範例

程式碼編輯器 (JavaScript)

// Define a Rectangle object.
var rectangle = ee.Geometry.Rectangle(-122.09, 37.42, -122.08, 37.43);

// Apply the simplify method to the Rectangle object.
var rectangleSimplify = rectangle.simplify({'maxError': 1});

// Print the result to the console.
print('rectangle.simplify(...) =', rectangleSimplify);

// Display relevant geometries on the map.
Map.setCenter(-122.085, 37.422, 15);
Map.addLayer(rectangle,
             {'color': 'black'},
             'Geometry [black]: rectangle');
Map.addLayer(rectangleSimplify,
             {'color': 'red'},
             'Result [red]: rectangle.simplify');

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

# Define a Rectangle object.
rectangle = ee.Geometry.Rectangle(-122.09, 37.42, -122.08, 37.43)

# Apply the simplify method to the Rectangle object.
rectangle_simplify = rectangle.simplify(maxError=1)

# Print the result.
display('rectangle.simplify(...) =', rectangle_simplify)

# Display relevant geometries on the map.
m = geemap.Map()
m.set_center(-122.085, 37.422, 15)
m.add_layer(rectangle, {'color': 'black'}, 'Geometry [black]: rectangle')
m.add_layer(
    rectangle_simplify, {'color': 'red'}, 'Result [red]: rectangle.simplify'
)
m