אפשר לייצא את FeatureCollection
כקובץ CSV, SHP (shapefile), GeoJSON, KML, KMZ או TFRecord באמצעות Export.table
. המשתנה FeatureCollection
יכול לייצג וקטורים או פשוט טבלת נתונים. במקרה השני, לתכונות באוסף תהיה גיאומטריה null.
חשוב לזכור כמה אילוצים נוספים כשעובדים עם פורמטים מסוימים של קבצים, כולל:
- KML: כשמייצאים קובץ
FeatureCollection
לקובץ KML, כל הגיאומטריות עוברות טרנספורמציה לקואורדינטות ללא הקרנה (WGS84). - SHP: קובץ
FeatureCollection
שיוצאו לקובץ Shapefile חייב להכיל תכונות עם אותו סוג גיאומטריה ותצוגה מראש, והוא חייב להתאים למגבלות הגודל של קובץ Shapefile. שמות העמודות מקוצרים ל-10 תווים או פחות, בלי ליצור שמות עמודה כפולים. - TFRecord: כאן מוסבר איך משתמשים ב-TFRecord.
ל-Cloud Storage
כדי לייצא FeatureCollection
ל-Cloud Storage, משתמשים ב-Export.table.toCloudStorage()
. לדוגמה, באמצעות features
שהוגדר קודם:
Code Editor (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' });
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
שהוגדר קודם:
Code Editor (JavaScript)
// Export an ee.FeatureCollection as an Earth Engine asset. Export.table.toAsset({ collection: features, description:'exportToTableAssetExample', assetId: 'exampleAssetId', });
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.
Code Editor (JavaScript)
Export.table.toBigQuery({ collection: features, table: 'myproject.mydataset.mytable', description: 'put_my_data_in_bigquery', append: true, overwrite: false });
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()
. לדוגמה:
Code Editor (JavaScript)
// Export the FeatureCollection to a KML file. Export.table.toDrive({ collection: features, description:'vectorsToDriveExample', fileFormat: 'KML' });
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 מתאים גם לייצוא טבלה עם גיאומטריה). כדי לייצא רק טבלת נתונים, ללא מידע גיאוגרפי, מייצאים תכונות עם גיאומטריה null בפורמט CSV. בדוגמה הבאה מוצגת שימוש ב-Export.table.toDrive()
כדי לקבל את התוצאות של הפחתה שעשויה לפעול זמן רב:
Code Editor (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' });
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 כי אין גיאומטריה בפלט.