Tried to filter an ee.ImageCollection using a property value but it is not working.
I have an image collection named my_col that I created using the map function. Although I have added one 'year' property to every image that the map function returns, and casted the year value explicitly as a number, like this:
// this is what the function is returning
return ee.Image(0)
// more processing
.set('year', ee.Number(ee.String(current_year_name)));
When I later use a filter to display the image of year of choice, it doesn't work:
Map.addLayer(my_col.filter(ee.Filter.eq('year', 2020)), viz_params, 2020);
But treating the year property as a string worked:
Map.addLayer(my_col.filter(ee.Filter.eq('year', 2020)), viz_params, '2020');
It is strange that the filter isn't working even after explicitly casting year as a ee.Number but whatever works works!?