Repository navigation
DelayedConvert feature - #1797
Merged
Merged
Conversation
Member
Author
|
@echeipesh ready for review |
echeipesh
requested changes
Nov 14, 2016
| newBands(b) = bandTile.map({ z => f(b, z) }) | ||
| else if (targetCellType.isFloatingPoint) | ||
| newBands(b) = bandTile.mapDouble({ z => z }) | ||
| else |
Contributor
There was a problem hiding this comment.
Useless else, this is already fixed in ArrayMultibandTile in this PR, just need to update here.
Member
Author
There was a problem hiding this comment.
They need to change cell type, so I changed these to use convert to be more explicit
| else if (targetCellType.isFloatingPoint) | ||
| newBands(b) = bandTile.mapDouble({ z => z}) | ||
| else | ||
| newBands(b) = bandTile.map({ z => z }) |
Contributor
|
+1 after review |
echeipesh
approved these changes
Nov 15, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This feature solves a very specific problem: Sometimes you want to
mapover a Tile, orcombinea MulitbandTile's bands, or the like, and have the resulting Tile be of a differentCellTypethen the original tile. For instance, when doing NDVI, if you do this on aIntConstantNoDataCellTypemultiband 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
delayedConversionmethod, which returns aTileorMultibandTilethat is exactly like the parent tile, except that for any method that produces aTileorMultibandTile, that resulting tile will be anArrayTileorArrayMultibandTilewith 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