0

I have created a small UI in which user will download the image when clicks on the download viewport button. But for some reason it gives me this error. How to fix it?

Line 15: Pixel grid dimensions (19814x15172) must be less than or equal to 10000. 

This is my code : https://code.earthengine.google.com/f5a405d34b98023635ab463753939730

//demo
var col = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED");
var image = col.filterBounds(geometry).filterDate('2022-02-01','2022-02-28').filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',10)).mosaic();
var ndvi = image.normalizedDifference(['B8','B4']);

function downloadImg() {
  var viewBounds = geometry;
  var downloadArgs = {
    name: 'NDVI_App_Export',
    crs: 'EPSG:4326', // or 3857
    scale: 10,
    region: viewBounds.toGeoJSONString(),
    maxPixels:1e9,
};
var url = ndvi.clip(geometry).getDownloadURL(downloadArgs);
urlLabel.setUrl(url);
urlLabel.style().set({shown: true});
}

// Add UI elements to the Map.
var downloadButton = ui.Button('Download viewport', downloadImg);
var urlLabel = ui.Label('Download', {shown: false});
var panel = ui.Panel([downloadButton, urlLabel]);
Map.add(panel);

Map.addLayer(ndvi,{min:0, max:1, palette:['yellow','green']},'NDVI')

1 Answer 1

1

You can't fix it. The maximum dimension is a hard limit set in the function, it is not a parameter. The reason for the limit is that the function is using the Interactive computing stack, which is meant for small requests that complete quickly (they time out at 5 minutes). The max dimension is a little arbitrary, but a limit needs to exist to try to avoid firing up a request that will time out. The limit is stated in the API reference docs.

2
  • 1
    I hear about this issue occasionally. I just did a feature request search but didn't find any open requests. I recommend you submit one for a solution to this problem of wanting to host an app where app users can download data that may be greater than the current limits (but still a reasonable sized image region). developers.google.com/earth-engine/help#feature_requests Commented Aug 15, 2022 at 23:58
  • Indeed, I read a previous answer of yours and I understand it that get url is a client side function. I will have to use code editor and export to GDrive. Thank you Justin
    – user173819
    Commented Aug 16, 2022 at 4:06

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.