0

I want to select specific bands together with an scale argument for each band in getDownloadURL, but I can't make it work.

var geometry = /* color: #d63000 */ee.Geometry.Polygon(
    [[[-3.1990814208984375, 10.698337865705495],
      [-3.2155609130859375, 10.50665993373459],
      [-2.63671875, 10.525563079495361],
      [-2.665557861328125, 10.714530481853876]]]);

var landsat = ee.Image(ee.ImageCollection("LANDSAT/LC08/C01/T2_TOA").first())
.clip(geometry)


print(landsat.getDownloadURL(
{
  'name': 'output',  
  'bands': [{id:'B1', scale:30}, {id:'B2', scale:100}]
}))      
Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
J.J
  • 51
  • 3
  • 5

2 Answers2

0

This feels like a bug in GEE, or inconsistency of the docs with the API. Your code looks fine and seems to follow docs. However, I never saw this bands argument used in practice. The reason is maybe that getDownloadURL is an older way to download data from GEE, I actually still use it in some scripts because it is simpler and does not require GDrive or GCS accounts, but can be unstable.

A workaround is to make your code work is to download these bands one by one, using desired scale: https://code.earthengine.google.com/13cfdb894d9e28831f39f3972b56baf7

print(landsat.select('B1').getDownloadURL({ scale: 30, region: region }))
print(landsat.select('B2').getDownloadURL({ scale: 100, region: region }))

If you use getDownloadURL - be prepared to implement a retry algorithm, to check if the downloaded zip file is valid, and retry download if it's not.

An alternative (recommended) way is to use Export: https://developers.google.com/earth-engine/exporting. For small preview images, ee.Image.getThumbURL can be used.

0

you must set the region parameter

var region = geometry.toGeoJSONString(); var path1 = rgbImage.getDownloadURL({'name':assetName,'format':'png','region':region,"scale": 10});