WorldWindJava
WorldWindJava copied to clipboard
No imagery using GDAL library with version > 3.0.0
Description
If GDAL version later than 3.0.0 is used, imagery won't be displayed.
Symptom: When a raster image is read by GDAL, the error
GDALWarpOptions.Validate(): nBandCount=0, no bands configured!
will be displayed. That will occur when the call to reprojectImage at line 1123 or 1135 to apply the mask dataset to the source image.
Problem analysis: The intent of the 'reprojectImage' call with the mask dataset was to produce a resulting dataset with alpha=0 outside the ROI, and 1.0 inside the ROI. The mask dataset is used to clip the image to the ROI by GDALUtils.composeDataRaster() (called in GDALDataRaster at line 1154). The alpha raster band is retrieved, and eventually used to clip the image in GDALUtils.applyImageMask.
With the GDAL code in this commit, the 'reprojectImage' for the mask dataset will fail, because GDAL finds no image bands (hence the error message). The alpha band in the mask dataset will be zero everywhere, and 'applyImageMask' will produce an empty image.
Steps to Reproduce
- Use a GDAL version later than 3.0.0. GISInternals has development releases for Windows.
- Run the 'InstallImagery' example.
- Note that the image is empty. Console output should include the error message noted above.
Reproduces how often: Always.
Operating System and Version
All
Additional Information
This is probably an improper use of 'reprojectImage'. Probably the masking operation should be done without the use of GDAL.
Confirmed that GDAL will not be changed. See this correspondence. I haven't been able to create a test case in which the mask would result in clipping. Such a case would result in an assignment of ALPHA_TRANSPARENT to a alpha pixel in GDALUtils at lines 966, 987, or 1008
@gbburkhardt, I think we should add this to the 2.3.0 release roadmap. For 2.2.0 we should probably stick with GDAL version 2. What do you think?
Sticking to GDAL <= 3.0.0 for the 2.2.0 release is fine with me. The problem described in this issue will affect us with version 3.0.1 2019-06-28 which is posted on gdal.org. GISInternals still has the 3.0.0 release which will work. I don't have a solution yet for this issue. I am considering whether the mask band feature can be used instead, but it hasn't been urgent for me to work on this.
Fixed with commit 7251ae6.