Skip to content

Commit

Permalink
fix nodata mismatch warps
Browse files Browse the repository at this point in the history
  • Loading branch information
hambsch committed Jun 26, 2024
1 parent e3a55d4 commit b6843b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/guppy/endpoints/upload_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def save_geotif_tiled_overviews(input_file: str, output_file: str, nodata: int)
with rasterio.open(input_file) as src:
target_crs = rasterio.crs.CRS.from_epsg(code=3857)
tmp_input_file = None
if src.crs != target_crs:
if src.crs != target_crs or nodata != src.nodata:
transform, width, height = rasterio.warp.calculate_default_transform(src.crs, target_crs, src.width, src.height, *src.bounds)
profile = src.profile
profile.update(crs=target_crs, transform=transform, width=width, height=height)
Expand All @@ -292,7 +292,8 @@ def save_geotif_tiled_overviews(input_file: str, output_file: str, nodata: int)
src_crs=src.crs,
dst_transform=transform,
dst_crs=target_crs,
resampling=rasterio.enums.Resampling.nearest
resampling=rasterio.enums.Resampling.nearest,
dst_nodata=nodata
)
if tmp_input_file:
os.remove(input_file)
Expand Down

0 comments on commit b6843b5

Please sign in to comment.