Skip to content

Commit

Permalink
Merge pull request #914 from girder/fix-nodata
Browse files Browse the repository at this point in the history
Fix styling with nodata.
  • Loading branch information
manthey authored Aug 5, 2022
2 parents 300898b + 8f36e91 commit 791da8e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Inheritable config files ([897](../../pull/897))
- Add geospatial property ([818](../../pull/818), [908](../../pull/908))
- Improve repr of image bytes ([902](../../pull/902))
- Handle nodata style when specified as a string ([914](../../pull/914))

### Changes
- Be more consistent in source class name attribute assignment ([884](../../pull/884))
Expand Down
2 changes: 1 addition & 1 deletion large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def _applyStyle(self, image, style, x, y, z, frame=None): # noqa
clamp = entry.get('clamp', True)
delta = max - min if max != min else 1
if nodata is not None:
keep = band != nodata
keep = band != float(nodata)
else:
keep = numpy.full(image.shape[:2], True)
band = (band - min) / delta
Expand Down
12 changes: 12 additions & 0 deletions test/test_source_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,15 @@ def testVfsCogValidation():
imagePath, projection='EPSG:3857', encoding='PNG')
with pytest.raises(TileSourceInefficientError):
source.validateCOG()


def testNoData():
imagePath = datastore.get_url('TC_NG_SFBay_US_Geo_COG.tif')
source = large_image_source_gdal.open(
imagePath, projection='EPSG:3857',
style={'bands': [{'band': 1, 'max': '100', 'min': '5', 'nodata': '0'}]})
assert source.getThumbnail()[0]
source = large_image_source_gdal.open(
imagePath, projection='EPSG:3857',
style={'bands': [{'band': 1, 'max': 100, 'min': 5, 'nodata': 0}]})
assert source.getThumbnail()[0]

0 comments on commit 791da8e

Please sign in to comment.