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

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

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

  • KML: FeatureCollection ที่ส่งออกไปยังไฟล์ KML จะมีการเปลี่ยนรูปแบบเรขาคณิตทั้งหมดเป็นพิกัดที่ไม่โปรเจ็กต์ (WGS84)
  • SHP: FeatureCollection ที่ส่งออกไปยัง Shapefile ต้องมีองค์ประกอบที่มีประเภทและโปรเจ็กชันเรขาคณิตเดียวกันและต้องอยู่ภายในขีดจำกัดขนาดของ Shapefile ระบบจะตัดชื่อคอลัมน์ให้เหลือไม่เกิน 10 อักขระ และชื่อคอลัมน์ต้องไม่ซ้ำกัน
  • 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" เนื่องจากไม่มีเรขาคณิตในเอาต์พุต