0

I want to create a layer that would have a pixel-specific list based on another layer. In this hypothetical scenario, the first layer contains the day when a change happened. Then, I want to create a layer of lists. For the pixel [1,1] the list would start at 4 and count up to the last day of the sequence (i.e. 10). So pixel [1,1] would contain a list as such: [4, 5, 6, 7, 8, 9, 10]. And pixel [1,3] would have a list as such: [8, 9, 10].

I started with this and suspect that I have to use map but not sure how to go about it.

var day = firstDay
var list = ee.List.sequence({start:day, count:(276-day)})

enter image description here

1 Answer 1

0

You can mimic a lot of list behavior on a per-pixel basis using Arrays. They have some specific differences than lists, but much of the same functionality exists for both. I'm not quite sure what your really trying to do in your example, but it might look something like this:

// An array that covers all possible answers.
var arr = ee.Image.constant(ee.Array(ee.List.sequence(0, 10)))

// Mask off everything up to the given day.
var match = arr.lt(days)
var result = match.arrayMask(match)

If your days correspond exactly to array index, then you could just use arraySlice to get to your initial state, instead of finding and then masking values you want to remove.

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.