gee-community / geetools

A collection of tools to work with Google Earth Engine Python API
https://geetools.readthedocs.io/en/stable/
MIT License
508 stars 121 forks source link

fix: add a format parameter to addDate method #245

Closed 12rambau closed 6 months ago

12rambau commented 6 months ago

This PR is blocked by this bug in the GEE API: https://issuetracker.google.com/issues/328859008

I want to avoid non regression so the case where we simply us the millis as a date need to remain. I cannot do:

ee.Algorithm.If(isMillis, date.millis(), ee.Number.parse(date.format(format)))

because it crashes when no format is provided.

The implemented solution works perfectly in javascript but is broken in Python API. I'll put it on stale until they come back to me or if someone has another server-side solution to this.

Fix #210

fitoprincipe commented 6 months ago

this is exactly why I had 2 different functions, one that creates date bands in relation to another date (epoch, start of the year, etc), and another for using the ee.Date.format to create the date band. I haven't found the pattern that returns milliseconds from epoch.

12rambau commented 6 months ago

@fitoprincipe, until the bug is solved from GEE side I think I find a workaround in my last commit, let me know if it matches your use case.