I'm using Google Earth Engine in Python, but I'm guessing this problem is not specific to Python. I want to use ee.Filter.calendarRange
on a feature collection. I was successful at using ee.Filter.calendarRange
for an image collection from images stored on the server. I think I need to use ee.ImageCollection.getRegion
to avoid doing computations on entire images. So, I am taking the output from getRegion and creating features from it that I'd like to do the computations on. The problem is that I don't know how to set feature dates in such a way that can be understood by ee.Filter.calendarRange
. I get EEException: Collection.filter: Can't apply calendarRange filter to objects without a timestamp.
.
I have an example code that creates 10 dates from Jan 1 to Jan 10, 2010 with "data" values from 0-9. I would like to create a feature collection with just the feature from Jan 3.
def make_fts( val ):
date = start_date.advance( ee.Number( val ), 'day' )
ft = ee.Feature( None, {'system:time_start': date, 'data': val} )
return ft
fake_vals = ee.List( [ee.Number( num ) for num in range(10)] )
start_date = ee.Date( '2010-01-01' )
fc = ee.FeatureCollection( fake_vals.map( make_fts ) )
day_ee_num = ee.Number( 3 )
day_filter = ee.Filter.calendarRange( day_ee_num, day_ee_num, 'day_of_month' )
day_three_fc = fc.filter( day_filter )