Fix: Assign NoData to a value outside of the valid data range for outputs of pgc_ortho.py and pgc_pansharpen.py #74
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.
I have tried two (cumulative) code changes to attempt to address the NoData issue (#73) for the subset of test images at
V:\pgc\data\common\quickbase\2204_UW_Andresen_Alaska_2023\imagery_check
.Attempt 1 - Modify the WarpImage function
I modified the
lib.ortho_functions.WarpImage
function to assign a NoData value to the destination file based on the specified data type of the destination file.I ran a test batch using the following command.
Note that I specified the wrong
--dem
VRT for the platform I was running on (WSL). The process complained that it couldn't find the reference rasters and thus the valid cell values aren't what they should be, but the NoData values behaved as expected for the output of this function.The change successfully set the NoData value to
65535
for the intermediate images that this function produces,ortho-16-rf-noDataTest/*_warp.tif.save
. However, the final images,ortho-16-rf-noDataTest/*.tif
still end up with a NoData value of0
.Attempt 2 - Modify the calcStats function
I modified
lib.ortho_functions.calcStats
, the function responsible for applying the stretch corrections. This is what is called on the warped image to produce the final output. I changed the hardcoded value passed tovds.GetRasterBand(band).SetNoDataValue(0)
from0
to65535
as that is what the incoming and outgoing NoData value should be for this specific set of images.I ran another test batch with the following command; fixing the
--dem
option.The final images have the NoData value set as
65535
as intended. However, the value of the NoData cells is modified by the stretching process, resulting in each band having a unique cell value in the NoData areas that is not65535
.