diff --git a/hybig/browse.py b/hybig/browse.py index d760cbf..89d9256 100644 --- a/hybig/browse.py +++ b/hybig/browse.py @@ -507,9 +507,13 @@ def write_georaster_as_browse( """ n_bands = raster.shape[0] - dst_nodata = NODATA_IDX + if color_map is not None: + dst_nodata = NODATA_IDX color_map[dst_nodata] = NODATA_RGBA + else: + # for banded data set the each band's destination nodata to zero (TRANSPARENT). + dst_nodata = TRANSPARENT creation_options = { **grid_parameters, diff --git a/tests/test_service/test_adapter.py b/tests/test_service/test_adapter.py index b3bc5cf..f4e87ff 100644 --- a/tests/test_service/test_adapter.py +++ b/tests/test_service/test_adapter.py @@ -456,7 +456,7 @@ def move_tif(*args, **kwargs): 'transform': expected_transform, 'driver': 'PNG', 'dtype': 'uint8', - 'dst_nodata': 255, + 'dst_nodata': 0, 'count': 3, } raster = convert_mulitband_to_raster(rio_data_array) @@ -476,7 +476,7 @@ def move_tif(*args, **kwargs): src_crs=rio_data_array.rio.crs, dst_transform=expected_params['transform'], dst_crs=expected_params['crs'], - dst_nodata=255, + dst_nodata=expected_params['dst_nodata'], resampling=Resampling.nearest, ) for band in range(4) diff --git a/tests/unit/test_browse.py b/tests/unit/test_browse.py index 667ea5c..dc89feb 100644 --- a/tests/unit/test_browse.py +++ b/tests/unit/test_browse.py @@ -237,7 +237,7 @@ def test_create_browse_imagery_with_mocks( src_crs=da_mock.rio.crs, dst_transform=target_transform, dst_crs=CRS.from_string('EPSG:4326'), - dst_nodata=255, + dst_nodata=0, resampling=Resampling.nearest, ), call( @@ -247,7 +247,7 @@ def test_create_browse_imagery_with_mocks( src_crs=da_mock.rio.crs, dst_transform=target_transform, dst_crs=CRS.from_string('EPSG:4326'), - dst_nodata=255, + dst_nodata=0, resampling=Resampling.nearest, ), call( @@ -257,7 +257,7 @@ def test_create_browse_imagery_with_mocks( src_crs=da_mock.rio.crs, dst_transform=target_transform, dst_crs=CRS.from_string('EPSG:4326'), - dst_nodata=255, + dst_nodata=0, resampling=Resampling.nearest, ), ]