0

I'm trying to export an Landsat image from GEE to a Drive, but the Export function that I applied gets 14 images (13 contain NoData and 1 the image). This is my code:

function applyScaleFactors(image) {
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
    return image.addBands(opticalBands, null, true); }
function maskClouds(image) {
  var cloudFree = bitwiseExtract(image.select('QA_PIXEL'), 0, 5).eq(0)
  return image
    .updateMask(cloudFree)
}

function bitwiseExtract(value, fromBit, toBit) {
  if (toBit === undefined)
    toBit = fromBit
  var maskSize = ee.Number(1).add(toBit).subtract(fromBit)
  var mask = ee.Number(1).leftShift(maskSize).subtract(1)
  return value.rightShift(fromBit).bitwiseAnd(mask)
}
var Addband_NDVI=function (image){
            var NDVI=image.normalizedDifference(['SR_B4','SR_B3']).rename('NDVI')
            return image.addBands(NDVI);} 
var collection = ee.ImageCollection("LANDSAT/LE07/C02/T1_L2")
  .filterDate('2000-01-01', '2001-01-01') // End date is exclusive
  .filter(ee.Filter.metadata('WRS_PATH', "greater_than", 171))
  .filter(ee.Filter.metadata('WRS_PATH', "less_than", 206)) 
  .filter(ee.Filter.metadata('WRS_ROW', "greater_than", 27)) 
  .filter(ee.Filter.metadata('WRS_ROW', "less_than", 37))
  .map(applyScaleFactors)
  .map(Addband_NDVI)
  .select('NDVI')
 
  
var pathRowCollection = ee.ImageCollection(ee.Join.saveAll('images')
  .apply({
    primary: collection
      .distinct(['WRS_PATH', 'WRS_ROW']), 
    secondary: collection, 
    condition: ee.Filter.and(
      ee.Filter.equals({leftField: 'WRS_PATH', rightField: 'WRS_PATH'}),
      ee.Filter.equals({leftField: 'WRS_ROW', rightField: 'WRS_ROW'})
    )
  })
  .map(function (image) {
    return ee.ImageCollection(ee.List(image.get('images')))
     .median()
     // Include row/path for the composite
      .copyProperties(image, ['WRS_PATH', 'WRS_PATH'])
  })
)
var ten= pathRowCollection.limit(1);
print(ten)
Map.addLayer(ten)
Export.image.toDrive({
  image: ten,
  scale:30,
  description: 'prova2M',
  region: geometry,
  maxPixels:3e12,
  crs: 'EPSG:4326'
});

My goal is export a single Landsat Image (as displayed on the map layer). Is there an other function that allows get this?

1

1 Answer 1

0

It wasn't completely clear from your question, but I assume you mean that in Google Drive, your exported image got split into multiple tiles.

A GeoTIFF cannot be bigger than 4 GB. If you have a larger area and/or many bands, you quite quickly hit that limit. EE will tile the exported GeoTIFF for you, to be able to get around this limit.

You can control the size of the tiles with the fileDimensions property on Export.image.toDrive(). As you didn't include the geometry in your question, it's impossible to tell if you will be able to fit your exported image into a single GeoTIFF by increasing fileDimensions.

If you're unable to fit your export into a single GeoTIFF, I suggest that you look into creating a VRT file for your tiles. Most tools are able to work with VRTs, and behaves just like if you had a single GeoTIFF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.