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 API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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