Skip to content

Commit

Permalink
Move WriteArray calls after SetNoDataValue calls (#555)
Browse files Browse the repository at this point in the history
As a precaution against striping found here: nasa/PROTEUS#54
  • Loading branch information
scottstanie authored Mar 7, 2025
1 parent f312d83 commit 912ee2c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/dolphin/io/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,9 @@ def write_arr(
if fi.geotransform is not None:
ds_out.SetGeoTransform(fi.geotransform)

# Write the actual data
if arr is not None:
if arr.ndim == 2:
arr = arr[np.newaxis, ...]
for i in range(fi.nbands):
logger.debug(f"Writing band {i+1}/{fi.nbands}")
bnd = ds_out.GetRasterBand(i + 1)
bnd.WriteArray(arr[i])

# Set the nodata/units/description for each band
for i in range(fi.nbands):
logger.debug(f"Setting nodata for band {i+1}/{fi.nbands}")
logger.debug(f"Setting nodata for band {i + 1}/{fi.nbands}")
bnd = ds_out.GetRasterBand(i + 1)
# Note: right now we're assuming the nodata/units/description
if fi.nodata is not None:
Expand All @@ -683,6 +674,15 @@ def write_arr(
if description is not None:
bnd.SetDescription(description)

# Write the actual data
if arr is not None:
if arr.ndim == 2:
arr = arr[np.newaxis, ...]
for i in range(fi.nbands):
logger.debug(f"Writing band {i + 1}/{fi.nbands}")
bnd = ds_out.GetRasterBand(i + 1)
bnd.WriteArray(arr[i])

ds_out.FlushCache()
ds_out = None

Expand Down

0 comments on commit 912ee2c

Please sign in to comment.