Export.table.toDrive

Tạo một tác vụ hàng loạt để xuất FeatureCollection dưới dạng bảng sang Drive. Bạn có thể bắt đầu việc cần làm từ thẻ Tasks.

Cách sử dụngGiá trị trả về
Export.table.toDrive(collection, description, folder, fileNamePrefix, fileFormat, selectors, maxVertices, priority)
Đối sốLoạiThông tin chi tiết
collectionFeatureCollectionBộ sưu tập đối tượng cần xuất.
descriptionChuỗi, không bắt buộcTên dễ đọc của việc cần làm. Có thể chứa chữ cái, số, dấu gạch ngang, dấu gạch dưới (không có dấu cách). Giá trị mặc định là "myExportTableTask".
folderChuỗi, không bắt buộcThư mục trên Google Drive nơi tệp xuất sẽ được lưu trữ. Lưu ý: (a) nếu tên thư mục tồn tại ở bất kỳ cấp độ nào, đầu ra sẽ được ghi vào đó, (b) nếu có tên thư mục trùng lặp, đầu ra sẽ được ghi vào thư mục được sửa đổi gần đây nhất, (c) nếu tên thư mục không tồn tại, một thư mục mới sẽ được tạo ở thư mục gốc và (d) tên thư mục có dấu phân cách (ví dụ: "path/to/file") được hiểu là chuỗi ký tự chứ không phải đường dẫn hệ thống. Giá trị mặc định là thư mục gốc của Drive.
fileNamePrefixChuỗi, không bắt buộcTiền tố tên tệp. Có thể chứa chữ cái, số, dấu gạch ngang, dấu gạch dưới (không có dấu cách). Giá trị mặc định là nội dung mô tả.
fileFormatChuỗi, không bắt buộcĐịnh dạng đầu ra: "CSV" (mặc định), "GeoJSON", "KML", "KMZ", "SHP" hoặc "TFRecord".
selectorsList<String>|String, không bắt buộcDanh sách các thuộc tính cần đưa vào tệp xuất; có thể là một chuỗi duy nhất có tên được phân tách bằng dấu phẩy hoặc một danh sách các chuỗi.
maxVerticesSố, không bắt buộcSố lượng đỉnh tối đa chưa cắt trên mỗi hình học; các hình học có nhiều đỉnh hơn sẽ được cắt thành các phần nhỏ hơn kích thước này.
prioritySố, không bắt buộcMức độ ưu tiên của công việc trong dự án. Các công việc có mức độ ưu tiên cao hơn sẽ được lên lịch sớm hơn. Phải là số nguyên từ 0 đến 9999. Giá trị mặc định là 100.

Ví dụ

Trình soạn thảo mã (JavaScript)

// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
Map.setCenter(-122.359, 37.428, 9);
Map.addLayer(img, {bands: ['B11', 'B8', 'B3'], min: 100, max: 3500}, 'img');

// Sample the image at 20 m scale, a point feature collection is returned.
var samp = img.sample({scale: 20, numPixels: 50, geometries: true});
Map.addLayer(samp, {color: 'white'}, 'samp');
print('Image sample feature collection', samp);

// Export the image sample feature collection to Drive as a CSV file.
Export.table.toDrive({
  collection: samp,
  description: 'image_sample_demo_csv',
  folder: 'earth_engine_demos',
  fileFormat: 'CSV'
});

// Export a subset of collection properties: three bands and the geometry
// as GeoJSON.
Export.table.toDrive({
  collection: samp,
  description: 'image_sample_demo_prop_subset',
  folder: 'earth_engine_demos',
  fileFormat: 'GeoJSON',
  selectors: ['B8', 'B11', 'B12', '.geo']
});

// Export the image sample feature collection to Drive as a shapefile.
Export.table.toDrive({
  collection: samp,
  description: 'image_sample_demo_shp',
  folder: 'earth_engine_demos',
  fileFormat: 'SHP'
});

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

import ee
import geemap.core as geemap

Colab (Python)

# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
m = geemap.Map()
m.set_center(-122.359, 37.428, 9)
m.add_layer(
    img, {'bands': ['B11', 'B8', 'B3'], 'min': 100, 'max': 3500}, 'img'
)

# Sample the image at 20 m scale, a point feature collection is returned.
samp = img.sample(scale=20, numPixels=50, geometries=True)
m.add_layer(samp, {'color': 'white'}, 'samp')
display(m)
display('Image sample feature collection', samp)

# Export the image sample feature collection to Drive as a CSV file.
task = ee.batch.Export.table.toDrive(
    collection=samp,
    description='image_sample_demo_csv',
    folder='earth_engine_demos',
    fileFormat='CSV',
)
task.start()

# Export a subset of collection properties: three bands and the geometry
# as GeoJSON.
task = ee.batch.Export.table.toDrive(
    collection=samp,
    description='image_sample_demo_prop_subset',
    folder='earth_engine_demos',
    fileFormat='GeoJSON',
    selectors=['B8', 'B11', 'B12', '.geo'],
)
task.start()

# Export the image sample feature collection to Drive as a shapefile.
task = ee.batch.Export.table.toDrive(
    collection=samp,
    description='image_sample_demo_shp',
    folder='earth_engine_demos',
    fileFormat='SHP',
)
task.start()