ee.Feature

特徵可由下列其中一個引數加上選用的屬性字典建構而成:

  - ee.Geometry。

  - GeoJSON 幾何圖形。

  - GeoJSON 特徵。

  - 計算出的物件:如果指定屬性,則重新解讀為幾何圖形;如果未指定屬性,則重新解讀為特徵。

用量傳回
ee.Feature(geometry, properties)功能
引數類型詳細資料
geometryComputedObject|Feature|Geometry|Object幾何圖形或特徵。
properties物件 (選用)中繼資料屬性字典。如果第一個參數是 Feature (而非幾何圖形),則不會使用這個參數。

範例

程式碼編輯器 (JavaScript)

// Create the simplest possible feature.
print(ee.Feature(null));  // Empty feature

// Demonstrate how to set a feature's id.
print(ee.Feature(null, {'id': 'yada'}).id());  // null
print(ee.Feature(null, {'system:index': 'abc123'}).id());  // abc123

// The simplest possible feature with a geometry.
var feature = ee.Feature(ee.Geometry.Point([-114.318, 38.985]));
Map.addLayer(feature);
Map.centerObject(feature, 10);

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

# Create the simplest possible feature.
display(ee.Feature(None))  # Empty feature

# Demonstrate how to set a feature's id.
display(ee.Feature(None, {'id': 'yada'}).id())  # None
display(ee.Feature(None, {'system:index': 'abc123'}).id())  # abc123

# The simplest possible feature with a geometry.
feature = ee.Feature(ee.Geometry.Point([-114.318, 38.985]))
m = geemap.Map()
m.add_layer(feature)
m.center_object(feature, 10)
m