您可以使用 Export.table
将 FeatureCollection
导出为 CSV、SHP (Shapefile)、GeoJSON、KML、KMZ 或 TFRecord。FeatureCollection
可以表示矢量,也可以只是一个数据表。在后一种情况下,集合中的地图项将具有 null 几何图形。
使用某些文件格式时,请注意以下额外限制:
- KML:导出为 KML 文件的
FeatureCollection
将会将所有几何图形转换为未投影 (WGS84) 坐标。 - SHP:导出为 Shapefile 的
FeatureCollection
必须包含几何图形类型和投影相同的特征,并且必须符合 Shapefile 大小限制。列名称会截断为 10 个字符或更少,并且不得造成重复的列名称。 - TFRecord:请参阅此页面。
到云端硬盘
如需将 FeatureCollection
导出到您的云端硬盘账号,请使用 Export.table.toDrive()
。例如:
Code Editor (JavaScript)
// Make a collection of points. var features = ee.FeatureCollection([ ee.Feature(ee.Geometry.Point(30.41, 59.933), {name: 'Voronoi'}), ee.Feature(ee.Geometry.Point(-73.96, 40.781), {name: 'Thiessen'}), ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {name: 'Dirichlet'}) ]); // Export the FeatureCollection to a KML file. Export.table.toDrive({ collection: features, description:'vectorsToDriveExample', fileFormat: 'KML' });
import ee import geemap.core as geemap
Colab (Python)
# Make a collection of points. features = ee.FeatureCollection([ ee.Feature(ee.Geometry.Point(30.41, 59.933), {'name': 'Voronoi'}), ee.Feature(ee.Geometry.Point(-73.96, 40.781), {'name': 'Thiessen'}), ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {'name': 'Dirichlet'}), ]) # Export the FeatureCollection to a KML file. task = ee.batch.Export.table.toDrive( collection=features, description='vectorsToDriveExample', fileFormat='KML' ) task.start()
请注意,输出格式指定为 KML 以处理地理数据(SHP 也适用于导出包含几何图形的表格)。如需仅导出数据表格(不含任何地理信息),请以 CSV 格式导出具有 null 几何图形的地图项。以下示例演示了如何使用 Export.table.toDrive()
获取可能长时间运行的求交集的结果:
Code Editor (JavaScript)
// Load a Landsat image. var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318'); var projection = image.select('B2').projection().getInfo(); // Create an arbitrary rectangle. var region = ee.Geometry.Rectangle(-122.2806, 37.1209, -122.0554, 37.2413); // Get a dictionary of means in the region. var means = image.reduceRegion({ reducer: ee.Reducer.mean(), geometry: region, crs: projection.crs, crsTransform: projection.transform, }); // Make a feature without geometry and set the properties to the dictionary of means. var feature = ee.Feature(null, means); // Wrap the Feature in a FeatureCollection for export. var featureCollection = ee.FeatureCollection([feature]); // Export the FeatureCollection. Export.table.toDrive({ collection: featureCollection, description: 'exportTableExample', fileFormat: 'CSV' });
import ee import geemap.core as geemap
Colab (Python)
# Load a Landsat image. image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318') projection = image.select('B2').projection().getInfo() # Create an arbitrary rectangle. region = ee.Geometry.Rectangle(-122.2806, 37.1209, -122.0554, 37.2413) # Get a dictionary of means in the region. means = image.reduceRegion( reducer=ee.Reducer.mean(), geometry=region, crs=projection['crs'], crsTransform=projection['transform'], ) # Make a feature without geometry and set the properties to the dictionary of means. feature = ee.Feature(None, means) # Wrap the Feature in a FeatureCollection for export. feature_collection = ee.FeatureCollection([feature]) # Export the FeatureCollection. task = ee.batch.Export.table.toDrive( collection=feature_collection, description='exportTableExample', fileFormat='CSV', ) task.start()
请注意,由于输出中没有几何图形,因此在此示例中将格式设置为“CSV”。
到 Cloud Storage
如需将 FeatureCollection
导出到 Cloud Storage,请使用 Export.table.toCloudStorage()
。例如,使用之前定义的 features
:
Code Editor (JavaScript)
// Export a KML file to Cloud Storage. Export.table.toCloudStorage({ collection: features, description:'vectorsToCloudStorageExample', bucket: 'your-bucket-name', fileNamePrefix: 'exampleTableExport', fileFormat: 'KML' });
import ee import geemap.core as geemap
Colab (Python)
# Export a KML file to Cloud Storage. task = ee.batch.Export.table.toCloudStorage( collection=features, description='vectorsToCloudStorageExample', bucket='your-bucket-name', fileNamePrefix='exampleTableExport', fileFormat='KML', ) task.start()
为资产
如需将 FeatureCollection
导出为 Earth Engine 资产,请使用 Export.table.toAsset()
。例如,使用之前定义的 features
:
Code Editor (JavaScript)
// Export an ee.FeatureCollection as an Earth Engine asset. Export.table.toAsset({ collection: features, description:'exportToTableAssetExample', assetId: 'exampleAssetId', });
import ee import geemap.core as geemap
Colab (Python)
# Export an ee.FeatureCollection as an Earth Engine asset. task = ee.batch.Export.table.toAsset( collection=features, description='exportToTableAssetExample', assetId='projects/your-project/assets/exampleAssetId', ) task.start()
Earth Engine 表资产的大小和形状存在一些限制:
- 地图项数量上限为 1 亿
- 最多 1,000 个属性(列)
- 每行几何图形的顶点数上限为 10 万个
- 每个字符串值的字符数上限为 10 万个