אפשר לייצא תמונות מ-Earth Engine בפורמט GeoTIFF או בפורמט TFRecord. אפשרויות נוספות להגדרת הפלט מפורטות בקטע פרמטרים של הגדרה.
דוגמה להגדרה
קודם מגדירים את נתוני התמונה שייוצאו:
Code Editor (JavaScript)
// Load a landsat image and select three bands. var landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_123032_20140515') .select(['B4', 'B3', 'B2']); // Create a geometry representing an export region. var geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);
import ee import geemap.core as geemap
Colab (Python)
# Load a landsat image and select three bands. landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_123032_20140515').select( ['B4', 'B3', 'B2'] ) # Create a geometry representing an export region. geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236])
בשלב הבא מגדירים את הפרמטרים של התחזית שישמשו בייצוא הבא. אנחנו משתמשים בפרמטר crs
כדי לציין את מערכת הקואורדינטות, ובפרמטר crsTransform
כדי לציין במדויק את רשת הפיקסלים. הפרמטר crsTransform
הוא רשימה של פרמטרים ממטריצה של טרנספורמציה אפינית בסדר שורה-ראשי [xScale, xShearing, xTranslation, yShearing, yScale, yTranslation]
. המקור של תמונה מוגדר על ידי הערכים xTranslation
ו-yTranslation
, וגודל התמונה בפיקסלים מוגדר על ידי הערכים xScale
ו-yScale
. דוגמאות למטריצות אליפטיות
Code Editor (JavaScript)
// Retrieve the projection information from a band of the original image. // Call getInfo() on the projection to request a client-side object containing // the crs and transform information needed for the client-side Export function. var projection = landsat.select('B2').projection().getInfo();
import ee import geemap.core as geemap
Colab (Python)
# Retrieve the projection information from a band of the original image. # Call getInfo() on the projection to request a client-side object containing # the crs and transform information needed for the client-side Export function. projection = landsat.select('B2').projection().getInfo()
ההגדרה scale
כקיצור דרך, אפשר לציין פרמטר scale
ומערכת Earth Engine תחשב בשבילכם את הפרמטר crsTransform
. עם זאת, הגדרת קנה המידה של תמונה לא מציינת את מקור התצוגה, ויכול להיות שהתמונה תזוז ביחס לתמונה אחרת באותו גודל פיקסלים.
הסיבה לשינוי הפוטנציאלי היא שהפרמטר scale
משמש לאכלוס הערכים xScale
ו-yScale
של crsTransform
, אבל הערכים xTranslation
ו-yTranslation
מחושבים כך שאם מחלקים אותם בערכי xScale
ו-yScale
התואמים, השארית תהיה אפס. הפרמטרים האלה מציינים רשת פיקסלים שבה מקור התצוגה הוא בפינה של פיקסל. המוסכמה הזו שונה מהפרמטרים של התרגום שבהם משתמשים חלק מספקי הנתונים, שמשתמשים ברשתות עם סטייה ממקור התצוגה. לדוגמה, בתמונות Landsat שסופקו על ידי USGS נעשה שימוש בפרמטרים של תרגום עם סטייה של חצי פיקסל ממקור התצוגה (סטייה של 15 מ' בתחומים של 30 מ'), ואילו בתמונות Sentinel-2 שסופקו על ידי ESA נעשה שימוש בפרמטרים של תרגום שמותאמים למקור התצוגה. אם הערך של crsTransform
שצוין בייצוא לא תואם לערך של crsTransform
בתמונה המקורית, הפיקסלים של הפלט יילקחו מחדש (באמצעות 'שכנה קרובה ביותר' כברירת מחדל), וכתוצאה מכך התמונה המתקבלת תזוז ביחס לתמונה המקורית.
לסיכום, אם אתם צריכים להתאים את הפיקסלים של התמונה המיוצאת לתמונה ספציפית, הקפידו להשתמש בפרמטרים crs
ו-crsTransform
כדי לשלוט באופן מלא בתצוגה של התמונה.
ל-Drive
כדי לייצא תמונה לחשבון Drive, משתמשים ב-Export.image.toDrive()
. לדוגמה, כדי לייצא חלקים מתמונה של Landsat, מגדירים אזור לייצוא ומפעילים את Export.image.toDrive()
:
Code Editor (JavaScript)
// Export the image, specifying the CRS, transform, and region. Export.image.toDrive({ image: landsat, description: 'imageToDriveExample_transform', crs: projection.crs, crsTransform: projection.transform, region: geometry });
import ee import geemap.core as geemap
Colab (Python)
# Export the image, specifying the CRS, transform, and region. task = ee.batch.Export.image.toDrive( image=landsat, description='imageToDriveExample_transform', crs=projection['crs'], crsTransform=projection['transform'], region=geometry, ) task.start()
כשמריצים את הקוד הזה, נוצרת משימה של ייצוא בכרטיסייה Tasks (משימות) של Code Editor. לוחצים על הלחצן הפעלה לצד המשימה כדי להפעיל אותה. (מידע נוסף על מנהל המשימות זמין בקטע 'עורך הקוד'). התמונה תיווצר בחשבון Drive שלכם עם fileFormat
שצוין.
ל-Cloud Storage
כדי לייצא תמונה לקטגוריה של Google Cloud Storage, משתמשים ב-Export.image.toCloudStorage()
. כדי לייצא את התמונה של Landsat מהדוגמה הקודמת ל-Cloud Storage במקום ל-Drive, משתמשים בקוד:
Code Editor (JavaScript)
// Export the image to Cloud Storage. Export.image.toCloudStorage({ image: landsat, description: 'imageToCloudExample', bucket: 'your-bucket-name', fileNamePrefix: 'exampleExport', crs: projection.crs, crsTransform: projection.transform, region: geometry });
import ee import geemap.core as geemap
Colab (Python)
# Export the image to Cloud Storage. task = ee.batch.Export.image.toCloudStorage( image=landsat, description='imageToCloudExample', bucket='your-bucket-name', fileNamePrefix='exampleExport', crs=projection['crs'], crsTransform=projection['transform'], region=geometry, ) task.start()
כמו בייצוא ל-Drive, מתחילים את הייצוא מהכרטיסייה משימות. המיקום של הקטגוריה ב-Cloud Storage יכול להשפיע על הביצועים ועל עלויות האחסון. מידע נוסף זמין בשאלות הנפוצות בנושא שיקולים לגבי מיקום.
לנכס
כדי לייצא תמונה לנכס בתיקיית הנכסים של Earth Engine, משתמשים ב-Export.image.toAsset()
. כדי לנהל את הנכסים ב-Earth Engine או לבדוק כמה ממכסת האחסון שלכם נמצאת בשימוש, אתם יכולים להשתמש במנהל הנכסים. הדוגמה הבאה ממחישה ייצוא של חלקים מתמונה של Landsat באמצעות מדיניות פירמידה שונה לאותה פס. מדיניות הפירמידה מציינת איך מערכת Earth Engine מחשבת גרסאות ברזולוציה נמוכה יותר של הנכס. במסמך בנושא שינוי רזולוציה מוסבר איך Earth Engine מטפל בכמה רזולוציות.
Code Editor (JavaScript)
// Get band 4 from the Landsat image, copy it. var band4 = landsat.select('B4').rename('b4_mean') .addBands(landsat.select('B4').rename('b4_sample')) .addBands(landsat.select('B4').rename('b4_max')); // Export the image to an Earth Engine asset. Export.image.toAsset({ image: band4, description: 'imageToAssetExample', assetId: 'exampleExport', crs: projection.crs, crsTransform: projection.transform, region: geometry, pyramidingPolicy: { 'b4_mean': 'mean', 'b4_sample': 'sample', 'b4_max': 'max' } });
import ee import geemap.core as geemap
Colab (Python)
# Get band 4 from the Landsat image, copy it. band_4 = ( landsat.select('B4') .rename('b4_mean') .addBands(landsat.select('B4').rename('b4_sample')) .addBands(landsat.select('B4').rename('b4_max')) ) # Export the image to an Earth Engine asset. task = ee.batch.Export.image.toAsset( image=band_4, description='imageToAssetExample', assetId='projects/your-project/assets/exampleExport', crs=projection['crs'], crsTransform=projection['transform'], region=geometry, pyramidingPolicy={ 'b4_mean': 'mean', 'b4_sample': 'sample', 'b4_max': 'max', }, ) task.start()
אפשר לספק מדיניות ברירת מחדל של פירמידה לכל תחום שלא צוין במפורש באמצעות המפתח '.default'
. אפשר גם להעביר רק את המפתח '.default'
. לדוגמה, כדי להגדיר כברירת מחדל את כל הלהקות למדיניות 'sample' של פירמידה, משתמשים ב-{'.default': 'sample'}
.
פרמטרים של הגדרות
שימו לב שמילון פרמטרים ההגדרה שמועברים אל Export.image
כולל את scale
(במטרים) ואת אזור הייצוא כ-ee.Geometry
. התמונה שיוצאו תכסה את האזור שצוין בפיקסלים בקנה המידה שצוין. אם לא מציינים זאת במפורש, מערכת CRS של הפלט תיבחר מהרצועה הראשונה של התמונה שמייצאים.
אפשר גם לציין את הערכים של dimensions
, crs
ו/או crsTransform
של התמונה המיוצאת. מידע נוסף על crs
ו-crsTransform
זמין במילון. לדוגמה, כדי לקבל בלוק של פיקסלים שמיושר בדיוק למקור נתונים אחר, מציינים את הערכים dimensions
, crs
ו-crsTransform
.
כדי לקבל בלוק של פיקסלים בגודל מוגדר מראש (למשל תמונה ממוזערת בגודל 256x256) שמכסה אזור, מציינים את הערכים dimensions
ו-region
.
אפשר לציין את פורמט הפלט של התמונה (אם היעד הוא לא toAsset()
) באמצעות הפרמטר fileFormat
('GeoTIFF'
כברירת מחדל).
הפרמטר formatOptions
אפשרויות הגדרה אחרות מוגדרות באמצעות הפרמטר formatOptions
, שהוא אמור להיות מילון עם מפתחות של אפשרויות פורמט אחרות, ספציפיות לכל fileFormat
, כפי שמתואר בהמשך.
GeoTIFF
GeoTIFF מותאם לענן
כדי לייצא קובץ GeoTIFF מותאם לענן, מעבירים ל-formatOptions
ליטרל של JavaScript שבו המפתח cloudOptimized
מוגדר ל-true. בהמשך לדוגמה הקודמת:
Code Editor (JavaScript)
// Export a cloud-optimized GeoTIFF. Export.image.toDrive({ image: landsat, description: 'imageToCOGeoTiffExample', crs: projection.crs, crsTransform: projection.transform, region: geometry, fileFormat: 'GeoTIFF', formatOptions: { cloudOptimized: true } });
import ee import geemap.core as geemap
Colab (Python)
# Export a cloud-optimized GeoTIFF. task = ee.batch.Export.image.toDrive( image=landsat, description='imageToCOGeoTiffExample', crs=projection['crs'], crsTransform=projection['transform'], region=geometry, fileFormat='GeoTIFF', formatOptions={'cloudOptimized': True}, ) task.start()
אפשר לטעון מחדש קובצי GeoTIFF שעברו אופטימיזציה לענן מ-Cloud Storage לקובץ Image
. פרטים נוספים זמינים במסמכי הסקירה הכללית של Image
.
Nodata
מציינים את ערך nodata של GeoTIFF באמצעות המפתח noData
בתוך הפרמטר formatOptions
. לדוגמה:
Code Editor (JavaScript)
// Set a nodata value and replace masked pixels around the image edge with it. var noDataVal = -9999; landsat = landsat.unmask(noDataVal); Export.image.toDrive({ image: landsat, description: 'imageNoDataExample', crs: projection.crs, scale: 2000, // large scale for minimal demo region: landsat.geometry(), // full image bounds fileFormat: 'GeoTIFF', formatOptions: { noData: noDataVal, } });
import ee import geemap.core as geemap
Colab (Python)
# Set a nodata value and replace masked pixels around the image edge with it. no_data_val = -9999 landsat = landsat.unmask(no_data_val) task = ee.batch.Export.image.toDrive( image=landsat, description='imageNoDataExample', crs=projection['crs'], scale=2000, # large scale for minimal demo region=landsat.geometry(), # full image bounds fileFormat='GeoTIFF', formatOptions={'noData': no_data_val}, ) task.start()
הערך של nodata צריך להיות בטווח החוקי של PixelType
של התמונה. אפשר לבדוק את הערך של PixelType
על ידי הדפסת המטא-נתונים של התמונה ובדיקה של המאפיין data_type
של הפס הראשון. אפשר גם להגדיר את הערך של PixelType
בתמונה על ידי הטמעת הנתונים לסוג ספציפי באמצעות שיטות התמונה toShort()
או toInt()
, לדוגמה.
TFRecord
אפשר לעיין בדף פורמט הנתונים של TFRecord.
maxPixels
הפרמטר maxPixels
נועד למנוע יצירה לא מכוונת של פעולות ייצוא גדולות מאוד. אם ערך ברירת המחדל נמוך מדי לתמונה היעד, אפשר להגדיל את maxPixels
. לדוגמה:
Export.image.toDrive({ image: landsat, description: 'maxPixelsExample', crs: projection.crs, crsTransform: projection.transform, region: geometry, maxPixels: 1e9 });
ייצוא קבצים גדולים
אם קובץ הפלט גדול, הוא ייצא כמספר קבצים. אם אתם מייצאים לקובצי GeoTIFF, התמונה תפוצל לריבועים. שם הקובץ של כל משבצת יהיה בפורמט baseFilename-yMin-xMin
, כאשר xMin
ו-yMin
הם הקואורדינטות של כל משבצת בתוך תיבת הגבול הכוללת של התמונה המיוצאת.
אם מייצאים ל-TFRecord, הקבצים יתווספו ב--00000
,-00001
,… -0000N
עבור N+1 קבצים. חשוב לשמור על הסדר הזה אם אתם מתכוונים לבצע הסקה על הקבצים ולהעלות את התחזיות חזרה ל-Earth Engine כתמונה. פרטים נוספים זמינים במאמר העלאת תמונות כקובצי TFRecord.
ייצוא תמונות כפי שהן מופיעות בעורך הקוד
כדי לייצא תמונות כפי שהן מוצגות במסך ב-Earth Engine, יוצרים תמונות של תצוגה חזותית כפי שמתואר בקטעים תמונות של תצוגה חזותית ושילוב ויצירת פסיפס. מכיוון ש-Code Editor משתמש ב-CRS 'EPSG:3857'
, צריך לציין CRS של 'EPSG:3857'
בייצוא כדי לקבל תמונה באותה הקרנה שמוצגת במפה של Code Editor. פרטים על ציון הרזולוציה ומערכת הקואורדינטות של הפלט מופיעים בקטע בנושא הגדרת ייצוא תמונות.