1

I came across something bizarre that I can't explain. When I run the following code,

var start = '1982-01-01'
var end = '2018-12-31'    
var aoi = ee.Geometry.Polygon([[-92.56227555674951,40.858223918075275],
                               [-92.56227555674951,40.85666590660416],
                               [-92.56227555674951,40.85666590660416],
                               [-92.55961480540674,40.85828883442468]]);


var chirps7a = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY")
                .filterDate(start,end)
                .filter(ee.Filter.dayOfYear(1,9))
                .filterBounds(aoi)
    print(chirps7a.size())
//returns 333 values, an odd number

    var chirps7b = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY")
                .filterDate(start,end)
                .filter(ee.Filter.dayOfYear(1,10))
                .filterBounds(aoi)
    print(chirps7b.size())
//returns 370 values, an even number, which makes sense considering the timespan is 36 years.

selecting 9 days returns 37 years worth of data, while having 10 days returns the desired 36. I'm sure there's something simple I've missed, but can someone point it out?

1 Answer 1

2

You have 37 years from 1982 till 2018, as 2018 is inclusive (you have set the end date at 31-12). Check the amount of years inside your collection using:

print('amount of years', ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY").filterDate(start,end).size().divide(365).round())

As a remeark, if you apply filterDate, and you set the end date at 31 december, the last years 31th of December is not included in your image collection. Better set end date at 2019-01-01. See link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.