I am trying to export some images from the Earth Engine using Export.image.toDrive
but it seems that all the files that I generate look corrupted.
When I mean corrupted, it means that if I open them with any viewer like Photoshop, Preview, etc, they look all black with lines (sample image at the bottom). Also I tried to open them with OpenCv in Python and the images did not have sense (they have three channels, but the number in the channels make no sense at all).
I looked for several examples online where people where exporting images and I couldn't find any difference with my code. Additionally, if I plot on the map of the Earth Engine the data seems to be fine. So I guess that I am doing something wrong with the exportation but I can't get it.
The procedure I follow is the following.
- I select an area of the map with the square tool.
- I run the script.
- I go to task and export some of the layers that appear there.
- I go to Drive and download the file to open it.
- File is corrupted :(.
code snippet
var s2 = ee.ImageCollection('COPERNICUS/S2') // Level-C1 (TOA), for Level-2A (BOA) use 'COPERNICUS/S2_SR'
.filterBounds(geometry)
.filter(ee.Filter.lessThanOrEquals('CLOUDY_PIXEL_PERCENTAGE', 50))
.filter(ee.Filter.date('2020-01-01', '2020-01-10'))
var clip_all = function(img){
return img.clip(geometry)
}
var s2_clip = s2.map(clip_all)
var s2_list = s2_clip.toList(s2_clip.size())
var n = s2_list.size().getInfo()
for (var i = 0; i < n; i++){
var img = ee.Image(s2_list.get(i))
var rgb = img.select('B2','B3', 'B4')//.float()
var date = img.date().format('yyyyMMdd').getInfo()
Map.addLayer(img, {bands: ['B4', 'B3', 'B2'], max: 5048}, 'Image_'+date)
//export
Export.image.toDrive({
image: rgb,
description: 'COPERNICUS_RGB'+ date,
scale: 30,
region: geometry,
maxPixels: 1e10,
fileNamePrefix: 'exampleExport',
folder: 'test_earthengine_2'
})
}
some variations that I tried:
- using another scale 30-->10, the same.
- adding float to the line var
rgb = img.select('B2','B3', 'B4').float()
, no changes.
I wonder if the problem is that the export can take really long time and the things that appear in my drive still need some processing? (I already waited for 8 hours and the files did not seem to change on my drive.)
When I mean corrupted this are the kind of images that I am obtaining: