-
Notifications
You must be signed in to change notification settings - Fork 122
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
handle "classification" bands #428
base: main
Are you sure you want to change the base?
Conversation
class_info = format_class_info(class_info) | ||
# I don't see the class info coming from the server, so it'll client side until I get challenged | ||
images = [] | ||
for class_value, class_name in class_info.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be possible to convert the dictionary of the classes into a ee object and thus change a bit the logic with 2 map
? I still have the hope that one day they will open extensibility of the javascript interface so we can port all these cool stuff to the code editor (that's why I'm forcing myself to always use ee computed object in the parameters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, I do this when the parameter can come from the server, for example, as it happens with the param styleProperty
in the method ee.FeatureCollection.style
. However, I find this confusing, because AFAIK you can use a dict
as a property only when you compute it on the fly, but you cannot store a dict
as a property when you save it as an GEE asset. If this is true (I tested it and seems to be true), to compute it on the fly you need to have it on the client-side, therefore I don't see the benefit of converting it to a server-side object and process it on the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could create a function that process/format it from STAC, but it'll still be on the client-side. We can do it on a follow-up PR.
band: band that contains class information | ||
|
||
Example: | ||
.. code-block:: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to use the jupyter-execute directive to see something here. you will need to use the documentation initialize parameter and display the image with plot
I think it would be nice for the user to see what it does in the documentation.
band: name of the bit band. Defaults to first band. | ||
|
||
Example: | ||
.. code-block:: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here let's make the example real
"""Test the ``classToBands`` method.""" | ||
class_info = {"3": "shadow", "9": "clouds_high", "11": "snow"} | ||
decoded = s2_class_image.geetools.classToBands(class_info, "SCL") | ||
aoi = ee.Geometry.Polygon( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make this AOI a fixture as you are rusing it in the next one
decoded = image.geetools.classToBands(class_info, "SCL") | ||
""" | ||
class_info = format_class_info(class_info) | ||
# I don't see the class info coming from the server, so it'll client side until I get challenged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eheh, here I am challenging you in the top comment of this PR ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same answer 😄
This is simlar to bits2bands, but in this case handling "classification" bands.
The main idea is to be able to handle a classification band using the same information as provided by GEE in the dataset's description, like the SCL band here. The only work the user needs to do is convert this:
to this:
It doesn't need to contain all classes but just the needed ones.