0

I have a feature collection (grids) and an image. Any ideas on how to filter only features that cover the image (only the unmasked part of the image which appears in the map layer)?

Here's the code: https://code.earthengine.google.com/16bfa4e762138a463bfe7bc3e2c738bd

var biome = ee.Image("OpenLandMap/PNV/PNV_BIOME-TYPE_BIOME00K_C/v01");
var tropical = biome.updateMask(biome.gte(1).and(biome.lte(3)));

var grid = american.coveringGrid('EPSG:4326', 500000); 

Map.addLayer(grid);
Map.addLayer(tropical);

For example, I want to select features only in the red part. enter image description here

2
  • You need to include a script in the question. A link to script in the Code Editor of GEE are also recomended. Commented Feb 9, 2023 at 14:03
  • Okay, thank you. I added the script link.
    – yoyo
    Commented Feb 10, 2023 at 14:06

1 Answer 1

0

I don't know any accurate and efficient ways to do that at scale. But this might be enough for your use-case?

var filtered = tropical
  .reduceRegions({
    collection: grid, 
    reducer: ee.Reducer.count(), 
    scale: 1000, 
  })
  .filter(ee.Filter.gt('count', 0))

https://code.earthengine.google.com/fc4d16a179a1aa0f829f816238d52b4b

1
  • Perfect!! Thank you very much!
    – yoyo
    Commented Feb 11, 2023 at 20:12

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.