ส่งออกข้อมูลตารางและเวกเตอร์

คุณสามารถส่งออก FeatureCollection เป็น CSV, SHP (Shapefile), GeoJSON, KML, KMZ หรือ TFRecord โดยใช้ Export.table FeatureCollection อาจแสดงเวกเตอร์หรือตารางข้อมูลธรรมดา ในกรณีหลัง องค์ประกอบในคอลเล็กชันจะมีเรขาคณิตเป็นค่าว่าง

โปรดทราบข้อจำกัดเพิ่มเติมเมื่อทำงานกับรูปแบบไฟล์บางรูปแบบ ซึ่งรวมถึงข้อจำกัดต่อไปนี้

  • KML: FeatureCollection ที่ส่งออกไปยังไฟล์ KML จะมีเรขาคณิตทั้งหมดที่เปลี่ยนรูปแบบเป็นพิกัดที่ไม่ได้ฉาย (WGS84)
  • SHP: FeatureCollection ที่ส่งออกไปยัง Shapefile ต้องมีฟีเจอร์ที่มีประเภทเรขาคณิตและการฉายภาพเดียวกัน และต้องมีขนาดไม่เกินขีดจำกัดขนาดของ Shapefile ชื่อคอลัมน์จะถูกตัดให้เหลือไม่เกิน 10 อักขระ และต้องไม่ทำให้เกิดชื่อคอลัมน์ที่ซ้ำกัน
  • TFRecord: ดูหน้ารูปแบบข้อมูล TFRecord

ไปยัง Cloud Storage

หากต้องการส่งออก FeatureCollection ไปยัง Cloud Storage ให้ใช้ Export.table.toCloudStorage() ตัวอย่างเช่น การใช้ features ที่กำหนดไว้ก่อนหน้านี้

ตัวแก้ไขโค้ด (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'
});

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้าสภาพแวดล้อม Python

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()

เป็นชิ้นงาน

หากต้องการส่งออก FeatureCollection เป็นชิ้นงาน Earth Engine ให้ใช้ Export.table.toAsset() ตัวอย่างเช่น การใช้ features ที่กำหนดไว้ก่อนหน้านี้

ตัวแก้ไขโค้ด (JavaScript)

// Export an ee.FeatureCollection as an Earth Engine asset.
Export.table.toAsset({
  collection: features,
  description:'exportToTableAssetExample',
  assetId: 'exampleAssetId',
});

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้าสภาพแวดล้อม Python

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 มีข้อจำกัดหลายประการ ดังนี้

  • ฟีเจอร์สูงสุด 100 ล้านรายการ
  • พร็อพเพอร์ตี้ (คอลัมน์) สูงสุด 1,000 รายการ
  • จุดยอดสูงสุด 100,000 จุดสำหรับเรขาคณิตของแต่ละแถว
  • ค่าสตริงแต่ละค่ามีอักขระได้สูงสุด 100,000 ตัว

ไปยัง BigQuery

คุณสามารถส่งออก FeatureCollection ไปยังตาราง BigQuery ได้โดยใช้ Export.table.toBigQuery() ซึ่งจะช่วยให้คุณผสานรวมข้อมูล Earth Engine กับข้อมูลและเครื่องมืออื่นๆ ที่มีใน BigQuery ได้ ดูข้อมูลเพิ่มเติมได้ที่คู่มือการส่งออกไปยัง BigQuery

ตัวแก้ไขโค้ด (JavaScript)

Export.table.toBigQuery({
  collection: features,
  table: 'myproject.mydataset.mytable',
  description: 'put_my_data_in_bigquery',
  append: true,
  overwrite: false
});

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้าสภาพแวดล้อม Python

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()

ไปยังไดรฟ์

หากต้องการส่งออก FeatureCollection ไปยังบัญชีไดรฟ์ ให้ใช้ Export.table.toDrive() เช่น

ตัวแก้ไขโค้ด (JavaScript)

// Export the FeatureCollection to a KML file.
Export.table.toDrive({
  collection: features,
  description:'vectorsToDriveExample',
  fileFormat: 'KML'
});

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้าสภาพแวดล้อม Python

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()

โปรดทราบว่ารูปแบบเอาต์พุตจะระบุเป็น KML เพื่อจัดการข้อมูลทางภูมิศาสตร์ (SHP ก็เหมาะสำหรับการส่งออกตารางที่มีเรขาคณิตด้วย) หากต้องการส่งออกเฉพาะตารางข้อมูลโดยไม่มีข้อมูลทางภูมิศาสตร์ ให้ส่งออกฟีเจอร์ที่มีเรขาคณิตเป็นค่าว่างในรูปแบบ CSV ตัวอย่างต่อไปนี้แสดงการใช้ Export.table.toDrive() เพื่อรับผลลัพธ์ของการลดที่อาจใช้เวลานาน

ตัวแก้ไขโค้ด (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'
});

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้าสภาพแวดล้อม Python

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" ในตัวอย่างนี้เนื่องจากไม่มีเรขาคณิตในเอาต์พุต