Skip to content

Commit

Permalink
Merge pull request #565 from girder/fix-noninteger-bands
Browse files Browse the repository at this point in the history
Fix an issue with non-integer GDAL sources.
  • Loading branch information
manthey authored Mar 11, 2021
2 parents 97d099e + 88fae0a commit 5ceb84d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
## Unreleased

### Improvements
- In Girder, prefer geospatial sources for geospatial data
- In Girder, prefer geospatial sources for geospatial data (#564)

### Bug Fixes
- The GDAL source failed when getting band ranges on non-integer data (#565)

## Version 1.4.2

Expand Down
15 changes: 10 additions & 5 deletions sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,16 @@ def _scanForMinMax(self, dtype, frame=None, analysisSize=1024):
}}
super(GDALFileTileSource, GDALFileTileSource)._scanForMinMax(
self, dtype=dtype, frame=frame, analysisSize=analysisSize, **kwargs)
self._bandRanges[frame]['min'] = numpy.append(
self._bandRanges[frame]['min'], 0)
self._bandRanges[frame]['max'] = numpy.append(
self._bandRanges[frame]['max'], numpy.iinfo(self._bandRanges[frame]['max'].dtype).max)
return
# Add the maximum range of the data type to the end of the band
# range list. This changes autoscaling behavior. For non-integer
# data types, this adds the range [0, 1].
self._bandRanges[frame]['min'] = numpy.append(self._bandRanges[frame]['min'], 0)
try:
# only valid for integer dtypes
range_max = numpy.iinfo(self._bandRanges[frame]['max'].dtype).max
except ValueError:
range_max = 1
self._bandRanges[frame]['max'] = numpy.append(self._bandRanges[frame]['max'], range_max)

def _getDriver(self):
"""
Expand Down

0 comments on commit 5ceb84d

Please sign in to comment.