Bạn có thể xuất FeatureCollection dưới dạng tệp CSV, SHP (shapefile), GeoJSON, KML, KMZ hoặc TFRecord bằng Export.table. FeatureCollection có thể đại diện cho vectơ
hoặc đơn giản là một bảng dữ liệu. Trong trường hợp sau, các đối tượng trong tập hợp sẽ có hình học rỗng.
Lưu ý một số quy tắc ràng buộc khác khi làm việc với một số định dạng tệp, bao gồm:
- KML:
FeatureCollectionđược xuất sang tệp KML sẽ có tất cả hình học được chuyển đổi thành toạ độ không được chiếu (WGS84). - SHP:
FeatureCollectionđược xuất sang Shapefile phải chứa các đối tượng có cùng loại hình học và phép chiếu, đồng thời phải nằm trong giới hạn kích thước của Shapefile. Tên cột được cắt bớt còn 10 ký tự trở xuống và việc này không được tạo ra tên cột trùng lặp. - TFRecord: Xem trang định dạng dữ liệu TFRecord.
vào Cloud Storage
Để xuất FeatureCollection sang Cloud Storage, hãy sử dụng Export.table.toCloudStorage(). Ví dụ: sử dụng features đã xác định trước đó:
Trình soạn thảo mã (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 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)
# 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 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()
vào Tài sản
Để xuất FeatureCollection dưới dạng tài sản Earth Engine, hãy sử dụng Export.table.toAsset(). Ví dụ: sử dụng features đã xác định trước đó:
Trình soạn thảo mã (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()
Có một số giới hạn về kích thước và hình dạng của tài sản bảng trong Earth Engine:
- Tối đa 100 triệu đối tượng
- Tối đa 1.000 thuộc tính (cột)
- Tối đa 100.000 đỉnh cho hình học của mỗi hàng
- Tối đa 100.000 ký tự cho mỗi giá trị chuỗi
vào BigQuery
Bạn có thể xuất FeatureCollection sang bảng BigQuery bằng cách sử dụng Export.table.toBigQuery().
Nhờ đó, bạn có thể tích hợp dữ liệu Earth Engine với các dữ liệu và công cụ khác có trong BigQuery. Để biết thêm thông tin, hãy xem
Hướng dẫn xuất sang BigQuery.
Trình soạn thảo mã (JavaScript)
Export.table.toBigQuery({ collection: features, table: 'myproject.mydataset.mytable', description: 'put_my_data_in_bigquery', append: true, overwrite: false });
import ee import geemap.core as geemap
Colab (Python)
task = ee.batch.Export.table.toBigQuery( collection=features, table='myproject.mydataset.mytable', description='put_my_data_in_bigquery', append=True, overwrite=False, ) task.start()
vào Drive
Để xuất FeatureCollection sang tài khoản Drive, hãy sử dụng Export.table.toDrive(). Ví dụ:
Trình soạn thảo mã (JavaScript)
// 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)
# Export the FeatureCollection to a KML file. task = ee.batch.Export.table.toDrive( collection=features, description='vectorsToDriveExample', fileFormat='KML' ) task.start()
Xin lưu ý rằng định dạng đầu ra được chỉ định là KML để xử lý dữ liệu địa lý (SHP cũng phù hợp để xuất bảng có hình học). Để chỉ xuất một bảng dữ liệu mà không có thông tin địa lý, hãy xuất các đối tượng có hình học rỗng ở định dạng CSV. Ví dụ sau đây minh hoạ cách sử dụng Export.table.toDrive() để nhận kết quả của một phép rút gọn có thể mất nhiều thời gian:
Trình soạn thảo mã (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()
Xin lưu ý rằng định dạng được đặt thành "CSV" trong ví dụ này vì không có hình học trong kết quả.