公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.Geometry.BBox.toGeoJSON
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
傳回幾何圖形的 GeoJSON 表示法。
用量 | 傳回 |
---|
BBox.toGeoJSON() | GeoJSONGeometry |
引數 | 類型 | 詳細資料 |
---|
這個:geometry | 幾何圖形 | Geometry 執行個體。 |
範例
程式碼編輯器 (JavaScript)
// Define a BBox object.
var bBox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43);
// Apply the toGeoJSON method to the BBox object.
var bBoxToGeoJSON = bBox.toGeoJSON();
// Print the result to the console.
print('bBox.toGeoJSON(...) =', bBoxToGeoJSON);
// Display relevant geometries on the map.
Map.setCenter(-122.085, 37.422, 15);
Map.addLayer(bBox,
{'color': 'black'},
'Geometry [black]: bBox');
Python 設定
請參閱
Python 環境頁面,瞭解 Python API 和如何使用 geemap
進行互動式開發。
import ee
import geemap.core as geemap
Colab (Python)
# Define a BBox object.
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43)
# Apply the toGeoJSON method to the BBox object.
bbox_to_geojson = bbox.toGeoJSON()
# Print the result.
display('bbox.toGeoJSON(...) =', bbox_to_geojson)
# Display relevant geometries on the map.
m = geemap.Map()
m.set_center(-122.085, 37.422, 15)
m.add_layer(bbox, {'color': 'black'}, 'Geometry [black]: bbox')
m
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[],["The `toGeoJSON()` method converts a Geometry instance, specifically a BBox, into a GeoJSON representation. It takes a Geometry object as input and returns its GeoJSON equivalent. Examples in JavaScript and Python demonstrate creating a BBox, applying `toGeoJSON()`, printing the result, and displaying the BBox on a map. Both examples define a BBox with coordinates (-122.09, 37.42, -122.08, 37.43).\n"],null,[]]