公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Feature
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
可以通过以下某个实参加上一个可选的属性字典来构建特征:
- 一种 ee.Geometry。
- GeoJSON 几何图形。
- GeoJSON 要素。
- 计算对象:如果指定了属性,则重新解释为几何图形;如果未指定属性,则重新解释为要素。
用法 | 返回 |
---|
ee.Feature(geometry, properties) | 功能 |
参数 | 类型 | 详细信息 |
---|
geometry | ComputedObject|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
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eee.Feature\u003c/code\u003e objects represent geographic features with geometry and properties, and can be constructed from geometries, GeoJSON, or computed objects.\u003c/p\u003e\n"],["\u003cp\u003eFeatures can have an optional dictionary of properties to store metadata.\u003c/p\u003e\n"],["\u003cp\u003eFeature IDs are determined by the \u003ccode\u003esystem:index\u003c/code\u003e property, if present, or by the \u003ccode\u003eid\u003c/code\u003e property as a fallback.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eee.Feature\u003c/code\u003e constructor provides a flexible way to create features with or without geometries and associated properties within Earth Engine.\u003c/p\u003e\n"],["\u003cp\u003eSimple features can be visualized on a map using \u003ccode\u003eMap.addLayer\u003c/code\u003e and \u003ccode\u003eMap.centerObject\u003c/code\u003e in JavaScript or similar functions in Python using \u003ccode\u003egeemap\u003c/code\u003e.\u003c/p\u003e\n"]]],["Features are created using a geometry (ee.Geometry, GeoJSON Geometry, or GeoJSON Feature) or a computed object, along with an optional dictionary of properties. `ee.Feature(geometry, properties)` creates a Feature. The `geometry` argument can be a geometry or another feature. The optional `properties` argument is a metadata dictionary; it's unused if the first argument is already a feature. A feature can be created without a geometry and an `id` or a `system:index` can be set.\n"],null,["# ee.Feature\n\n\u003cbr /\u003e\n\nFeatures can be constructed from one of the following arguments plus an optional dictionary of properties:\n\n\u003cbr /\u003e\n\n- An ee.Geometry.\n\n- A GeoJSON Geometry.\n\n- A GeoJSON Feature.\n\n- A computed object: reinterpreted as a geometry if properties are specified, and as a feature if they aren't.\n\n| Usage | Returns |\n|----------------------------------------|---------|\n| `ee.Feature(geometry, `*properties*`)` | Feature |\n\n| Argument | Type | Details |\n|--------------|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------|\n| `geometry` | ComputedObject\\|Feature\\|Geometry\\|Object | A geometry or feature. |\n| `properties` | Object, optional | A dictionary of metadata properties. If the first parameter is a Feature (instead of a geometry), this is unused. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create the simplest possible feature.\nprint(ee.Feature(null)); // Empty feature\n\n// Demonstrate how to set a feature's id.\nprint(ee.Feature(null, {'id': 'yada'}).id()); // null\nprint(ee.Feature(null, {'system:index': 'abc123'}).id()); // abc123\n\n// The simplest possible feature with a geometry.\nvar feature = ee.Feature(ee.Geometry.Point([-114.318, 38.985]));\nMap.addLayer(feature);\nMap.centerObject(feature, 10);\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Create the simplest possible feature.\ndisplay(ee.Feature(None)) # Empty feature\n\n# Demonstrate how to set a feature's id.\ndisplay(ee.Feature(None, {'id': 'yada'}).id()) # None\ndisplay(ee.Feature(None, {'system:index': 'abc123'}).id()) # abc123\n\n# The simplest possible feature with a geometry.\nfeature = ee.Feature(ee.Geometry.Point([-114.318, 38.985]))\nm = geemap.Map()\nm.add_layer(feature)\nm.center_object(feature, 10)\nm\n```"]]