Skip to content

Commit

Permalink
DAS-2276: Write transparent backgrounds when regrid dest has nodata
Browse files Browse the repository at this point in the history
fix previous assumption that the 255 value is set to an RGBA value for
transparency. Now we are writing rgba without the quantization.
  • Loading branch information
flamingbear committed Dec 16, 2024
1 parent 25742bf commit dd09815
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion hybig/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_service/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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,
),
]
Expand Down

0 comments on commit dd09815

Please sign in to comment.