1

I'm trying to use filterBounds on an ImageCollection using the geometry function taken from a FeatureCollection but no changes appear. I don't understand why it won't work as I'm passing the geometry into filterBounds.

import geemap
import ee

Map = geemap.Map()
Map

# retreives geometry for colorado
co = ee.FeatureCollection('TIGER/2018/States').filter("NAME == 'Colorado'").geometry()

# clips image to colorado geometry
lf_veg_dataset = ee.ImageCollection('LANDFIRE/Vegetation/EVT/v1_4_0').filterBounds(co);

# selects dataset to be mapped
lf_veg = lf_veg_dataset.select('EVT')

# sets image variables
lf_veg_vis = {'min': 3001, 'max': 3999, 'opacity': 1.0}

# adds image layers to map
Map.addLayer(lf_veg, lf_veg_vis, 'Veg')
prime90
  • 889
  • 2
  • 14
  • 26

1 Answers1

2

filterBounds() passes elements of the input collection that have geometries intersecting the geometry - see also here: https://gis.stackexchange.com/questions/247955/clipping-vs-filtering-images-with-a-polygon-google-earth-engine. In your case this means that the filter returns an IC that covers all states except for AK and HI. You just need to clip that output to your region of interest:

import geemap
import ee

Map = geemap.Map()

# retreives geometry for colorado
co = ee.FeatureCollection('TIGER/2018/States').filterMetadata('NAME', 'equals', 'Colorado').geometry()

# clips image to colorado geometry
lf_veg_dataset = ee.ImageCollection('LANDFIRE/Vegetation/EVT/v1_4_0').filterBounds(co)

# selects dataset to be mapped
lf_veg = lf_veg_dataset.select('EVT')

# Clip to bounds of geometry
lf_veg_img = lf_veg.map(lambda image: image.clip(co))

# sets image variables
lf_veg_vis = {'min': 3001, 'max': 3999, 'opacity': 1.0}

# adds image layers to map
Map.addLayer(lf_veg_img, lf_veg_vis, 'Veg')

Map
hooge048
  • 224
  • 1
  • 4