Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix styling with nodata. #914

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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]