0

I'm wondering how to extract values from a ee.List and ee.Array that meet a certain criteria in the Google Earth engine environment.

var array1 = ee.Array([1,1,2,2,3,3,4,4])
var list1 = ee.List([1,1,2,2,3,3,4,4])

I was thinking in the lines of filtering but I don't know the property to filter on, should I .set() that beforehand somehow?

var output = list1.filter(ee.Filter.gt('Item',2)) 

I assume I should use .slice for the array, but can't find an example that uses slice on a filtered array or conditional statement.

Wondering if somebody can guide me in the correct direction!

Regards

0

You can mask() an array using a conditional:

var array1 = ee.Array([1,1,2,2,3,3,4,4])
var masked = array1.mask(array1.eq(2))

You can't however mask a list. But you can filter it the way you've already mentioned (filter using 'item').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.