Utilize Google Earth Engine to specify bands when using the ee.Image.getDownloadURL() function

I am trying to specify certain bands along with a corresponding scale argument for each band in the getDownloadURL function, but I'm having trouble getting it to function correctly.

var area = /* 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(area)

print(landsat.getDownloadURL(
{
  'name': 'output',  
  'bands': [{id:'B1', scale:30}, {id:'B2', scale:100}]
}))      

Answer №1

It seems like there may be a glitch in GEE, or there could be a discrepancy between the documentation and the API. Your code appears to be correct and aligns with the documentation. However, I have never actually seen the bands argument being used in practice. This could be because getDownloadURL is considered an older method for downloading data from GEE. Despite this, I still use it in some scripts as it is simpler and does not require accounts for GDrive or GCS, although it can sometimes be unreliable.

To work around this issue, you can download each band individually at the desired scale. Here is an example script:

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

If you do decide to use getDownloadURL, make sure to implement a retry algorithm to verify the downloaded zip file's validity and retry the download if necessary.

An alternative (and recommended) approach is to utilize Export: https://developers.google.com/earth-engine/exporting. For small preview images, consider using ee.Image.getThumbURL.

Answer №2

Make sure to specify the region parameter when setting up

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What Could be Causing the Error: Invalid Hook Invocation?

I'm encountering an issue with reading undefined props. I attempted to destructure props, but I require the hook calls. Is there a way for me to destructure props within a function or another method to solve this problem? ProductBrowse.jsx is respons ...

Using Dropzone.js to bypass the Browse dialog when uploading files in integration tests with php-webdriver

Currently, I am implementing dropzone.js in my project. I have a specific requirement where I need to manually add a file to the queue without triggering the file browser dialog box. The dropzone has been initialized on the element with the class .imageDro ...

Send your information to a JSONP endpoint

Can data be posted to JsonP instead of passing it in the querystring as a GET request? I have a large amount of data that needs to be sent to a cross-domain service, and sending it via the querystring is not feasible due to its size. What other alternati ...

Ways to customize date format based on locale in AngularJS

Currently using a German PC with browser locale set to de. Also installed the following JS library: <script src="//code.angularjs.org/1.5.6/i18n/angular-locale_de-de.js"></script> The issue is that {{mydate | date:'shortDate'}} stil ...

Having trouble finding the element during Selenium JavaScript testing

I need help testing a JavaScript script using Selenium, but I am running into an issue. I cannot seem to find a specific element that I want to click on. Here is a snippet of my JS code where I am trying to click on the Shipping option. I have tried us ...

hover over the picture with your cursor

Struggling with jquery and css, could use some assistance :) Check out my html code below: <html> <head> //myscripts <script> $(document).ready(function(){ $(".cover").hover(function(){ //the function i need to write } ...

Identify the difference between a regular function and a constructor in JavaScript

How can we determine whether a function in javascript is a simple, plain (anonymous) function, or a constructor (a function with a prototype)? I have developed the following function for this purpose: function checkFunctionType(value) { var ownPropert ...

Issues encountered with JSON formatting following jQuery ajax request

When my nodejs app receives data from a cordova app through a jQuery ajax call, the format is different. It looks like this: { "network[msisdn]": "+254738XXXXXX", "network[country]": "ke", "network[roaming]": "false", "network[simSt ...

Optimizing the Placement of Dynamic Google Maps

After setting up a responsive Google map using this jsFiddle and guidance from this stack overflow post, I encountered an issue. How can I keep the map centered on the marker across various viewports and browser sizes? I came across a solution in this res ...

The request to the route timed out after waiting 5000ms for a response from the server

I am a newcomer to using Cypress and I'm exploring an HTML page for testing purposes. My goal is to test the login authentication and log the body of an XHR. Here's the test code I wrote for this: describe('Login test', function () { ...

Developing a password strength checker using Javascript for ultimate security

Currently encountering an issue with my javascript project. The main goal is to validate user input against a list of known bad passwords and also their "1337" versions. Initially, checking for the basic bad password list was straightforward. However, th ...

Best method for distributing components across nextjs zones?

Scenario: I am currently working on a project using Next.js and taking advantage of its multi zones feature. This feature allows us to run multiple independent NextJS applications as a unified app, managed by different teams. The Issue: One challenge I fa ...

Tips on using the Unix "paste" command in Node.js without the need to load entire files into memory

Implementing the basic Unix paste command in Python is straightforward, as shown in the following snippet (which currently processes two files, unlike Unix paste that can handle multiple files): def pasteFiles(file1, file2): with open(file1) as f1: w ...

Issue with AjaxSetup overlapping with jqgrid

How can I set up global AJAX calls using ajaxsetup without interfering with the functionality of jqgrids on my website? I want to apply the code below to my AJAX calls, excluding those related to jqgrids. $.ajaxSetup({ type: "POST", contentType: ...

Is it possible to use tabs.create to generate a tab and then inject a content script, where the code attribute is effective but the file attribute seems to be ineffective

I am currently facing an issue with injecting a content script file into a newly created tab. The problem lies in the fact that I keep receiving an error stating chrome.tabs.executeScript(...) is undefined in the console output of the Popup. It may be wort ...

Guide on how to align h1 in the navigation bar

I've been attempting to center text on a nav bar but haven't been successful. What could I be overlooking? // include external modules import React, { Component } from "react"; import { Navbar } from "reactstrap"; import { Menu } from " ...

Sharing information between External JavaScript and React JS/Redux

Incorporating React-redux into an externalJs application (built on a custom JS framework) has posed a challenge for me. I am trying to initialize data for the Redux store from externalJS, but it seems that the external script is unable to access the React ...

Custom Vue Basic String Renderer for JSONForms

I'm delving into Vue JSONForms and attempting to develop a basic custom text renderer from scratch. While I am aware of the vue-vanilla package available in JSONForms, I want to grasp the fundamental requirements for creating a custom renderer as I an ...

Is there a method to programmatically clear cache in an Angular 7 application?

I am facing an issue with my component that lazy loads images. The first time the page loads, the images are displayed using lazy loading. However, if I refresh, reload, or close and reopen the tab, the images are pre-loaded from the cache. Is there a wa ...

AJAX parsing through JSON files generated by PHP

Need help with sending a json to an ajax call and reading it when it's sent. Plus, the json structure seems off due to the backslashes... This is the ajax function in question: function find(){ var type = $('#object_type').val( ...