0

I am trying to perform various operations on MODIS datasets in google earth engine.

Every operation I try to perform is prevented by the requirement in code to select a band to work with.

This collection: MODIS/MCD43A4_006_NDVI' has no bands. It shows up in the console as

bands: [] when I perform any operation that requires selecting or manipulating bands.

part of the code I've tried is this:

  .filter(ee.Filter.calendarRange(startyear,endyear,'year'))
  .filter(ee.Filter.calendarRange(startmonth,endmonth,'month'))
  .sort('system:time_start')
  // .filterBounds(ROI)
  .select('NDVI');

I can't select NDVI, which I need later in the code, because I can't select anything with this dataset--there are no bands. I can't add a band, since the information is already there, NDVI and day of year, but apparently not stored in a band.

How can I use this dataset in operations that require selection of a band?

2
  • 3
    Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 4.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work?
    – Glorfindel
    Commented Jul 22, 2020 at 16:35
  • 2
    Please don't vandalize posts. You've asked a question, which another user has spent time in answering. Please be respectful of their time in leaving the question intact. If you have a different question feel free to ask it separately. If your question has been answered please mark as answered
    – Midavalo
    Commented Jul 24, 2020 at 1:36

1 Answer 1

2

The bands field present when printing an image collection does not indicate exactly what bands the images in that collection have. It only specifies that, if any bands are listed there, all images in the collection do have those named bands. Each image may have more bands than the ones listed. (The bands information is only present in certain simple cases such as examining an image asset.)

You can look at each image within a collection to see what bands that image has:

Screenshot of console with image expanded

Similarly, from code:

print(collection.first().bandNames());     // will print ["NDVI"]
5
  • @Justin Please edit your question with a complete code sample that shows how your attempt to use the selected band fails -- I just tried a simple script to display it which succeeded, so there must be more going on. The problem is not "this band doesn't exist", it's something else in your code, and giving us a complete example that fails will help. The collection bands field is a red herring.
    – Kevin Reid
    Commented Jul 22, 2020 at 2:30
  • @Justin I see you added some code, but it doesn't run. I tried editing it to display NDVIsubsetyear and that image is fully masked, which does not mean the band is missing; you'd get an error if the band was missing. I strongly recommend that you work on simplifying your code to demonstrate the problem. Don't try to preserve everything you were doing (like selecting particular dates); discard everything that's not relevant to demonstrating the problem. This will not only help us answer your question, it will help you see where the problem is. You might even figure it out yourself!
    – Kevin Reid
    Commented Jul 22, 2020 at 3:35
  • @Justin I'd perhaps start by throwing out the years.map part. Do whatever it is you are doing for one year only. Then simplify further. Get rid of filtering and arithmetic. Remember, the goal is not to have code that computes anything scientifically meaningful; the goal is to come up with the simplest code you can that doesn't do what you think it should do,
    – Kevin Reid
    Commented Jul 22, 2020 at 4:43
  • @Justin Comments on an answer are not the place for additional questions -- if you have another question about how Earth Engine works ask it separately, so that it can be of benefit to others. This comment thread is already problematically long. As to annualList -- I am not saying that you should throw out the contents of the function. I'm saying you should move the contents to the top level and apply the calculation to just one date. Then, you can start modifying the code to further simplify it without the constraint of it being in a particular shape of map.
    – Kevin Reid
    Commented Jul 22, 2020 at 14:42
  • 1
    @Justin Another suggestion: you still haven't presented what the new problem is. Your original question as I answered it seemed clear: "this image seems to be missing its bands". Now, you've got some code that doesn't work, but you haven't told us how it doesn't work. Do you get an error message, or is the image not as expected? It might be best to post a new question, since this question-and-answer pair go together even if the answer doesn't solve your original problem.
    – Kevin Reid
    Commented Jul 22, 2020 at 14:44

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.