تصدير بيانات الجداول والأشكال الهندسية

يمكنك تصدير FeatureCollection بتنسيق CSV أو SHP (ملف Shapefile) أو GeoJSON أو KML أو KMZ أو TFRecord باستخدام Export.table. قد يمثّل الرمز FeatureCollection المتجهات أو جدول بيانات ببساطة. وفي الحالة الأخيرة، ستحمل العناصر في المجموعة هندسة صفرية.

يُرجى ملاحظة بعض القيود الإضافية عند العمل مع بعض تنسيقات الملفات، بما في ذلك:

  • 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 للحصول على معلومات عن واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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 للحصول على معلومات عن واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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 للحصول على معلومات عن واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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

إلى Drive

لتصدير FeatureCollection إلى حسابك على Drive، استخدِم Export.table.toDrive(). على سبيل المثال:

محرِّر الرموز البرمجية (JavaScript)

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

إعداد Python

اطّلِع على صفحة بيئة Python للحصول على معلومات عن واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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 للحصول على معلومات عن واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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" في هذا المثال لأنّه لا يتضمّن أيّ هندسة في الإخراج.