0

I want to export an NDVI map for the Quebec province, Canada, from GEE so that I can select my sampling locations after importing the map on QGIS. But I get this error:

Error: Export too large: specified 8030040147504 pixels (max: 1000). Specify higher maxPixels value if you intend to export a large area. (Error code: 3)

I tried to look at videos on YouTube and read answers to similar questions on StackExchange, but the examples are for one type of Landsat and not for a mix of two Landsats.

Can you help me with modifying the code?

Here is the link to the script: https://code.earthengine.google.com/0ca4247b9b45abbece8491289b65a878

Here is the code:

var S2 = ee.ImageCollection("LANDSAT/LT05/C02/T1_L2")
var S9 = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")


// to add Geometry
var addNDVI = function(image) {
  var ndvi = image
    .clip(geometry)
    .normalizedDifference(['SR_B4', 'SR_B3'])
    .rename('NDVI');
  return image.addBands(ndvi);
};

var addNDVI2 = function(image) {
  var ndvi = image
    .normalizedDifference(['SR_B5', 'SR_B4'])
    .rename('NDVI');
  return image.addBands(ndvi);
};
// Filter par date et calculer la mosaique
var withNDVI = S2.map(addNDVI).filterDate('1988-06-15', '2012-08-30').qualityMosaic('NDVI').select('NDVI');
var withNDVI_2 = S9.map(addNDVI2).filterDate('2013-06-15', '2022-08-30').qualityMosaic('NDVI').select('NDVI');

var NDVI_diff = withNDVI_2.subtract(withNDVI)

var ndviParams = {min: -1.5, max: 1.5, palette: ['black', 'white', 'green']};

//visualiser sur la carte
Map.centerObject(geometry)
Map.addLayer(NDVI_diff, ndviParams, 'NDVI image');

// Exporter l'image vers Drive.
Export.image.toDrive({
  image: withNDVI,
  description: 'NDVI-1985',
  scale: 10,
  fileFormat: 'GeoTIFF',
  formatOptions: {
    cloudOptimized: true
  },
  maxPixels: 1e13
});

1 Answer 1

2

You are trying to export the whole world in 10m scale:

print(NDVI_diff.geometry())

Polygon, 5 vertices type: Polygon coordinates: List (1 element) 0: List (5 elements) 0: [-180,-90] 1: [180,-90] 2: [180,90] 3: [-180,90] 4: [-180,-90]

You can explicitly specify the region when exporting.

Export.image.toDrive({
  image: withNDVI,
  description: 'NDVI-1985',
  region: geometry,
  scale: 10,
  fileFormat: 'GeoTIFF',
  formatOptions: {
    cloudOptimized: true
  },
  maxPixels: 1e13
})

Also, avoid clip() until the last step of your processing, as it's quite costly. Here, you're doing it when mapping over the collection. Instead, clip the image you add to the map.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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