公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
FeatureCollection 概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
一组相关地图项可以合并到一个 FeatureCollection
中,以便对整个集合执行其他操作,例如过滤、排序和渲染。
除了简单地图项(几何图形 + 属性)之外,地图项集合还可以包含其他集合。
FeatureCollection
构造函数
创建 FeatureCollection
的一种方法是向构造函数提供一系列功能。这些地图项不必具有相同的几何图形类型或相同的属性。例如:
Code Editor (JavaScript)
// Make a list of Features.
var features = [
ee.Feature(ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {name: 'Voronoi'}),
ee.Feature(ee.Geometry.Point(-73.96, 40.781), {name: 'Thiessen'}),
ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {name: 'Dirichlet'})
];
// Create a FeatureCollection from the list and print it.
var fromList = ee.FeatureCollection(features);
print(fromList);
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Make a list of Features.
features = [
ee.Feature(
ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {'name': 'Voronoi'}
),
ee.Feature(ee.Geometry.Point(-73.96, 40.781), {'name': 'Thiessen'}),
ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {'name': 'Dirichlet'}),
]
# Create a FeatureCollection from the list and print it.
from_list = ee.FeatureCollection(features)
display(from_list)
单个几何图形也可以转换为仅包含一个 Feature
的 FeatureCollection
:
Code Editor (JavaScript)
// Create a FeatureCollection from a single geometry and print it.
var fromGeom = ee.FeatureCollection(ee.Geometry.Point(16.37, 48.225));
print(fromGeom);
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Create a FeatureCollection from a single geometry and print it.
from_geom = ee.FeatureCollection(ee.Geometry.Point(16.37, 48.225))
display(from_geom)
表格数据集
Earth Engine 托管各种表数据集。如需加载表数据集,请向 FeatureCollection
构造函数提供表 ID。例如,如需加载 RESOLVE 生态区域数据,请执行以下操作:
Code Editor (JavaScript)
var fc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017');
Map.setCenter(12.17, 20.96, 3);
Map.addLayer(fc, {}, 'ecoregions');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
fc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')
m = geemap.Map()
m.set_center(12.17, 20.96, 3)
m.add_layer(fc, {}, 'ecoregions')
display(m)
请注意,与图片数据集一样,您可以在 Earth Engine Data Catalog 中搜索表格数据集。
随机抽样
如需获取指定区域中的一组随机点,您可以使用以下方法:
Code Editor (JavaScript)
// Define an arbitrary region in which to compute random points.
var region = ee.Geometry.Rectangle(-119.224, 34.669, -99.536, 50.064);
// Create 1000 random points in the region.
var randomPoints = ee.FeatureCollection.randomPoints(region);
// Display the points.
Map.centerObject(randomPoints);
Map.addLayer(randomPoints, {}, 'random points');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Define an arbitrary region in which to compute random points.
region = ee.Geometry.Rectangle(-119.224, 34.669, -99.536, 50.064)
# Create 1000 random points in the region.
random_points = ee.FeatureCollection.randomPoints(region)
# Display the points.
m = geemap.Map()
m.center_object(random_points)
m.add_layer(random_points, {}, 'random points')
display(m)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003eFeatureCollection\u003c/code\u003es group related features, enabling operations like filtering, sorting, and rendering.\u003c/p\u003e\n"],["\u003cp\u003eYou can create \u003ccode\u003eFeatureCollection\u003c/code\u003es using a list of features, a single geometry, or by loading a table dataset using its ID.\u003c/p\u003e\n"],["\u003cp\u003eEarth Engine provides access to various table datasets, searchable in the Data Catalog.\u003c/p\u003e\n"],["\u003cp\u003eRandom point samples within a specified region can be generated using \u003ccode\u003eee.FeatureCollection.randomPoints()\u003c/code\u003e.\u003c/p\u003e\n"]]],["`FeatureCollection` combines related features, enabling operations like filtering and sorting. You can create one by providing a list of features, even with varied geometries and properties, or from a single geometry. Loading table datasets is done by using the `FeatureCollection` constructor with a table ID. The `randomPoints` method generates random points within a region, and both table data and random points can be displayed.\n"],null,["# FeatureCollection Overview\n\nGroups of related features can be combined into a `FeatureCollection`, to\nenable additional operations on the entire set such as filtering, sorting and rendering.\nBesides just simple features (geometry + properties), feature collections can also contain\nother collections.\n\nThe `FeatureCollection` constructor\n-----------------------------------\n\nOne way to create a `FeatureCollection` is to provide the constructor with\na list of features. The features don't need to have the same geometry type or the same\nproperties. For example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Make a list of Features.\nvar features = [\n ee.Feature(ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {name: 'Voronoi'}),\n ee.Feature(ee.Geometry.Point(-73.96, 40.781), {name: 'Thiessen'}),\n ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {name: 'Dirichlet'})\n];\n\n// Create a FeatureCollection from the list and print it.\nvar fromList = ee.FeatureCollection(features);\nprint(fromList);\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# Make a list of Features.\nfeatures = [\n ee.Feature(\n ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {'name': 'Voronoi'}\n ),\n ee.Feature(ee.Geometry.Point(-73.96, 40.781), {'name': 'Thiessen'}),\n ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {'name': 'Dirichlet'}),\n]\n\n# Create a FeatureCollection from the list and print it.\nfrom_list = ee.FeatureCollection(features)\ndisplay(from_list)\n```\n\nIndividual geometries can also be turned into a `FeatureCollection` of\njust one `Feature`:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create a FeatureCollection from a single geometry and print it.\nvar fromGeom = ee.FeatureCollection(ee.Geometry.Point(16.37, 48.225));\nprint(fromGeom);\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 a FeatureCollection from a single geometry and print it.\nfrom_geom = ee.FeatureCollection(ee.Geometry.Point(16.37, 48.225))\ndisplay(from_geom)\n```\n\n### Table Datasets\n\nEarth Engine hosts a variety of table datasets. To load a table dataset, provide the\ntable ID to the `FeatureCollection` constructor. For example, to load\nRESOLVE Ecoregions data:\n\n### Code Editor (JavaScript)\n\n```javascript\nvar fc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017');\nMap.setCenter(12.17, 20.96, 3);\nMap.addLayer(fc, {}, 'ecoregions');\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\nfc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')\nm = geemap.Map()\nm.set_center(12.17, 20.96, 3)\nm.add_layer(fc, {}, 'ecoregions')\ndisplay(m)\n```\n\nNote that as with image datasets, you can search for table datasets in the\n[Earth Engine Data Catalog](/earth-engine/datasets).\n\n### Random Samples\n\nTo get a collection of random points in a specified region, you can use:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Define an arbitrary region in which to compute random points.\nvar region = ee.Geometry.Rectangle(-119.224, 34.669, -99.536, 50.064);\n\n// Create 1000 random points in the region.\nvar randomPoints = ee.FeatureCollection.randomPoints(region);\n\n// Display the points.\nMap.centerObject(randomPoints);\nMap.addLayer(randomPoints, {}, 'random points');\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# Define an arbitrary region in which to compute random points.\nregion = ee.Geometry.Rectangle(-119.224, 34.669, -99.536, 50.064)\n\n# Create 1000 random points in the region.\nrandom_points = ee.FeatureCollection.randomPoints(region)\n\n# Display the points.\nm = geemap.Map()\nm.center_object(random_points)\nm.add_layer(random_points, {}, 'random points')\ndisplay(m)\n```"]]