1

I very new to earth engine but I can't seem to figure out how to create a list of countries that I can then use to filter larger datasets from. The point of this is that I want to use the Hansen data on forest cover change but only in protected areas in specific countries. I managed to get it to filter one country at a time but doing this separately for each country seems unnecessarily tedious.

var myStringArrayGFW = ['gain','lossyear'];
var dataset_name = "UMD/hansen/global_forest_change_2015_v1_8"; 
var dataset = ee.Image(dataset_name);
var myStringArray = myStringArrayGFW;
  
var filtered_country = myStringArrayGFW.filter(ee.Filter.eq('ADM0_NAME', 'Mexico'));

1 Answer 1

1

One approach can be:

var filter=['Mexico','Peru','Guinea']//your list
var filtered_country = countries.filter(ee.Filter.inList('ADM0_NAME', filter));

var AOI=hansen.select(myStringArrayGFW).clip(filtered_country)

Here an example link

1

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.