-
Notifications
You must be signed in to change notification settings - Fork 109
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
Band expression for MultiBaseReader #524
Comments
I've added a |
I like this. We are breaking things anyways so might as well get it right now. Representing the full hierarchy of asset::band seems like the best way to support applying expressions across multi-band assets.
I think appending
Can asset expressions be removed entirely if a user can pass assets to the # one asset_expression
asset_expression={"green": "b1+2", "red": "b1+3"}
# two expressions
expression="green_b1+2"
expression="green_b1+3" Applying multiple expressions like this would be much easier if with STACReader("stac.json") as stac:
ima = stac.tile(701, 102, 8)
first_expression = ima.apply_expression("green_b1+2")
second_expression = ima.apply_expression("green_b1+2")
third_exression = ima.apply_expression("green_b1+2/red_b1") This example ☝️ got me thinking that maybe including |
🙏 thanks @geospatial-jeff
+1
I think yes! +1
Yes, just one thing: in your example you still need a way to tell the with STACReader("stac.json") as stac:
ima = stac.tile(701, 102, 8, assets=("green", "red"))
first_expression = ima.apply_expression("green_b1+2")
second_expression = ima.apply_expression("green_b1+2")
third_exression = ima.apply_expression("green_b1+2/red_b1")
Sadly we still need to pass the expression to |
ref #523 (comment)
Right now when passing
expression
to MultiBaseReader (STAC) methods, we assume each asset is one band e.g:if one asset has more than one band and if no other option is set, the result could be unexpected.
The way
expression
works is by usingwhere we assign a
name
to each band within the numpy arrayIn ☝️ we have a 3 bands data but a 2 bands list ("b1", "b2"), and we construct the dict that will be passed
numexpr
. We can see that no errors is raised while we have 3 bands and only 2 names.Proposal
with #523 we now have bands names all the way during the processes, e.g
It means that in theory expression could be in form of
expression="green_b1/red_b1"
internally rio-tiler will know that for expression
"green_b1/red_b1"
we want to read assetsgreen
andred
. Then we will have an image with band_names="green_b1", "red_b1"
. Those names will be used in theapply_expresion
directly because apply_expression is a new method of the ImageData classrio-tiler/rio_tiler/models.py
Lines 278 to 283 in 55ae897
potential issue
Another question is what happens when we use
asset_expression
?☝️ we have then a band name that is
"green_b1+2"
so if we wanted to use expression we would have to writeexpression= "green_b1+2/red_b1"
but that won't work because rio-tiler will try to parse the main expression and re-apply!+2
togreen_b1+2
!!!One solution would be to use
_b1
as the first band of the asset even if there is expression applied.Status Quo ?
While I feel ☝️ is better, I understand that it's a big breaking change.
The text was updated successfully, but these errors were encountered: