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 tác vụ trên thẻ Tác vụ.

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
collectionFeatureCollectionTập hợp đối tượng địa lý cần xuất.
descriptionChuỗi, không bắt buộcTên tác vụ mà con người có thể đọc được. Có thể chứa chữ cái, số, -, _ (không có dấu cách). Giá trị mặc định là "myExportTableTask".
folderChuỗi, không bắt buộcThư mục Google Drive mà tệp xuất sẽ nằm trong đó. Lưu ý: (a) nếu tên thư mục tồn tại ở bất kỳ cấp nào, thì đầu ra sẽ được ghi vào đó, (b) nếu tên thư mục trùng lặp tồn tại, thì đầ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, thì 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 tách (ví dụ: "path/to/file") được hiểu là chuỗi ký tự, 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ố, -, _ (không có dấu cách). Giá trị mặc định là phần 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 có tên được phân tách bằng dấu phẩy hoặc danh sách các chuỗi.
maxVerticesSố, không bắt buộcSố đỉnh tối đa chưa cắt cho 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 tác vụ trong dự án. Các tác vụ 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ề Python API và cách sử dụng geemap cho quá trình phát triển có tính 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()