-
Notifications
You must be signed in to change notification settings - Fork 361
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
DelayedConvert feature #1797
DelayedConvert feature #1797
Conversation
@echeipesh ready for review |
newBands(b) = bandTile.map({ z => f(b, z) }) | ||
else if (targetCellType.isFloatingPoint) | ||
newBands(b) = bandTile.mapDouble({ z => z }) | ||
else |
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.
Useless else, this is already fixed in ArrayMultibandTile
in this PR, just need to update here.
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.
They need to change cell type, so I changed these to use convert
to be more explicit
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.
Ah, that's right.
else if (targetCellType.isFloatingPoint) | ||
newBands(b) = bandTile.mapDouble({ z => z}) | ||
else | ||
newBands(b) = bandTile.map({ z => z }) |
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.
ditto above
+1 after review |
This feature solves a very specific problem: Sometimes you want to
map
over a Tile, orcombine
a MulitbandTile's bands, or the like, and have the resulting Tile be of a differentCellType
then the original tile. For instance, when doing NDVI, if you do this on aIntConstantNoDataCellType
multiband raster:You'll get garbage values, since the ratio produces results from [-1, 1], but our result tile will be
IntConstantNoDataCelltype
, which will not hold the floating point values. What you have to do now is convert it to a floating point valued raster first:This is awful for performance, because not only do you have to iterate over band 3 and 4 to set each value to a double value before you do the combine, but this will actually iterate over bands you don't even care about. What you can do to get around the latter issue is this:
but that doesn't not solve the latter problem.
This solves this particular brand of problem by creating a
delayedConversion
method, which returns aTile
orMultibandTile
that is exactly like the parent tile, except that for any method that produces aTile
orMultibandTile
, that resulting tile will be anArrayTile
orArrayMultibandTile
with the target cell type. Our NDVI calculation now becomes:And now we do the thing we want: iterate over band 3 and 4 only, and set the double NDVI value into a
DoubleConstantNoDataCellType
.NOTE
Also contained in this PR is some ArrayMultibandTile optimizations.
Connects #1410