TransWikia.com

Empty TIFF files while exporting images using Google Earth Engine

Geographic Information Systems Asked by stalker_of_the_stack on August 8, 2021

I am trying to export aerial images of a city in Japan. I have specified a polygon geometry of the location and also specified it as region in export. But I am getting blank TIFFs in the drive as output. What could have gone wrong?

print('started running script');
var landsat8_col = {
  l8_reflect_tier1:ee.ImageCollection("LANDSAT/LC08/C01/T1_SR"),
  l8_reflect_tier2:ee.ImageCollection("LANDSAT/LC08/C01/T2_SR"),
  l8_atmosphere_tier1:ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA"),
  l8_atmosphere_tier2:ee.ImageCollection("LANDSAT/LC08/C01/T2_TOA"),
  l8_raw_tier1:ee.ImageCollection("LANDSAT/LC08/C01/T1"),
  l8_raw_tier2:ee.ImageCollection("LANDSAT/LC08/C01/T2")
}

var landsat7_col = {
  l7_reflect_tier1:ee.ImageCollection("LANDSAT/LC07/C01/T1_SR"),
  l7_reflect_tier2:ee.ImageCollection("LANDSAT/LC07/C01/T2_SR"),
  l7_atmosphere_tier1:ee.ImageCollection("LANDSAT/LC07/C01/T1_TOA"),
  l7_atmosphere_tier2:ee.ImageCollection("LANDSAT/LC07/C01/T2_TOA"),
  l7_raw_tier1:ee.ImageCollection("LANDSAT/LC07/C01/T1"),
  l7_raw_tier2:ee.ImageCollection("LANDSAT/LC07/C01/T2")
}

var l8_dates = [['2015-01-01','2018-05-31']]

var l7_dates = [['2008-01-01','2008-12-31']]

var point_of_interest = ee.Geometry.Point([137.95,35.72])

var polygon_of_interest = ee.Geometry.Polygon([
          [
            [
              137.93982982635498,
              35.728313419207375
            ],
            [
              137.94046819210052,
              35.728313419207375
            ],
            [
              137.94046819210052,
              35.729663398270645
            ],
            [
              137.93982982635498,
              35.729663398270645
            ],
            [
              137.93982982635498,
              35.728313419207375
            ]
          ]
        ]);

var l8_keys = Object.keys(landsat8_col)
var l7_keys = Object.keys(landsat7_col)


var l8_values = Object.keys(landsat8_col).map(function(key) {
    return landsat8_col[key];
});
var l7_values = Object.keys(landsat7_col).map(function(key) {
    return landsat7_col[key];
});

function getFilteredImages(img_collections,dates,point_of_interest){
  var filtered_imgs = [];
  img_collections.forEach(function(img_collection){
    var img = img_collection.filterBounds(geometry).filterDate(dates[0][0],dates[0][1]).sort('CLOUD_COVER').first();
    filtered_imgs.push(img);
    print(img);
  });
  return filtered_imgs;
}


function export_images(imgs_col){
  for(var i=0;i<imgs_col.length;i++){
    Export.image.toDrive({
      image: imgs_col[i].select(['B4','B3','B2']),
      description: l8_keys[i],
      scale: 1000,
      maxPixels:1e13,
      region:polygon_of_interest,
      fileFormat: 'GeoTIFF',
      folder:"2"
    });
  }
}


var filtered_imgs = getFilteredImages(l8_values,l8_dates,point_of_interest);
var vizParams = {
  bands: ['B4', 'B3', 'B2'],
  min: 0,
  max:1000,
  gamma: [0.95, 1.5, 2]
};

export_images(filtered_imgs);
print('Done');

One Answer

The images were exported correctly, but the image data is from all the bands and hence mac preview is not able to understand the image. What worked for me was: using img.visualize({bands: ['B4', 'B3', 'B2'], min: 6000, max: 20000});

This creates a human viewable RGB image and when we export this image, we can see the contents of the image.

Correct answer by stalker_of_the_stack on August 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP