Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance ee.String.geetools.format with numbers and dates formatters #443

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fitoprincipe
Copy link
Member

In previous versions of batch.Export.imagecollection.toAsset the user was able to choose a format pattern to format the name of the images. This inspired me on enhancing the ee.String.geetools.format method to accept formatters. It adds a bit of complexity by using ee.Algorithms.If twice, but I belive it's not big deal when dealing with strings. Other option could be creating a different method to address this situation.

This is realted to #430.

@fitoprincipe fitoprincipe requested a review from 12rambau March 7, 2025 19:58
Copy link
Member

@12rambau 12rambau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem for me here I like the approach a lot.

side note, could we align on how Python deals with format in the format function i.e. ":" instead of the "%" sign ?

>>> a = 10.1234
>>> f'{a:.2f}'
'10.12'

@fitoprincipe
Copy link
Member Author

Hm, I am not sure about that. I was planning to use this improved method in ee.batch.Export.imagecollection.toAsset, allowing the user to use any image property in the param namePattern, including system properties like system:time_start, which already contains the proposed character :. For example,

ee.batch.Export.imagecollection.toAsset(
  collection = s2col,
  namePattern: "S2_{system:time_start%tyyyy-MM-dd}",
  assetId = "projects/...."
)

Handling this would involve more conditionals and would be a bit confusing for the user. I'm not 100% sure that % cannot be used as a property name, but it's less common.

Also, I though on being inline with GEE formatters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants