صادر کردن داده‌های برداری و جدول

می‌توانید FeatureCollection را بااستفاده از Export.table به‌صورت CSV،‏ SHP (شیپ‌فایل)، GeoJSON،‏ KML،‏ KMZ، یا TFRecord صادر کنید. FeatureCollection ممکن است نشان‌دهنده بردارها یا صرفاً جدولی از داده‌ها باشد. در حالت دوم، عارضه‌های موجود در مجموعه هندسه تهی خواهند داشت.

هنگام کار با برخی‌از قالب‌های فایل، به برخی محدودیت‌های اضافی توجه کنید، ازجمله:

  • KML: FeatureCollection صادرشده به فایل KML همه هندسه‌ها را به مختصات غیرتصویری (WGS84) تبدیل می‌کند.
  • SHP: FeatureCollection صادرشده به Shapefile باید دارای عارضه‌هایی با نوع هندسه و تصویر یکسان باشد و باید در محدودیت‌های اندازه Shapefile بگنجد. نام ستون‌ها به ۱۰ نویسه یا کمتر کوتاه می‌شود و این کار نباید نام ستون تکراری ایجاد کند.
  • TFRecord: به صفحه قالب داده TFRecord مراجعه کنید.

به فضای ذخیره‌سازی ابری

برای صادر کردن FeatureCollection به Cloud Storage، از Export.table.toCloudStorage() استفاده کنید. برای مثال، بااستفاده از features که قبلاً تعریف شده است:

ویرایشگر کد (جاوا اسکریپت)

// 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 Environment مراجعه کنید.

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 که قبلاً تعریف شده است:

ویرایشگر کد (جاوا اسکریپت)

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

راه‌اندازی Python

برای اطلاعات درباره Python API و استفاده از geemap برای توسعه تعاملی، به صفحه Python Environment مراجعه کنید.

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 وجود دارد:

  • حداکثر ۱۰۰ میلیون عارضه
  • حداکثر ۱٬۰۰۰ ویژگی (ستون)
  • حداکثر ۱۰۰٬۰۰۰ رأس برای هندسه هر ردیف
  • حداکثر ۱۰۰٬۰۰۰ نویسه برای هر مقدار رشته

به BigQuery

می‌توانید FeatureCollection را بااستفاده از Export.table.toBigQuery() به جدول BigQuery صادر کنید. این کار به شما امکان می‌دهد داده‌های Earth Engine خود را با داده‌ها و ابزارهای دیگر موجود در BigQuery ادغام کنید. برای اطلاعات بیشتر، راهنمای صادر کردن به BigQuery را ببینید.

ویرایشگر کد (جاوا اسکریپت)

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

راه‌اندازی Python

برای اطلاعات درباره Python API و استفاده از geemap برای توسعه تعاملی، به صفحه Python Environment مراجعه کنید.

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() استفاده کنید. برای مثال:

ویرایشگر کد (جاوا اسکریپت)

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

راه‌اندازی Python

برای اطلاعات درباره Python API و استفاده از geemap برای توسعه تعاملی، به صفحه Python Environment مراجعه کنید.

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() برای دریافت نتایج کاهش احتمالاً طولانی‌مدت نشان داده شده است:

ویرایشگر کد (جاوا اسکریپت)

// 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 Environment مراجعه کنید.

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» تنظیم شده است زیرا هیچ هندسه‌ای در برونداد وجود ندارد.