to_geotiff accepts tile_size values that violate the TIFF 6 spec.
The spec requires TileWidth and TileLength to be multiples of 16. The current validation in xrspatial/geotiff/__init__.py only checks that tile_size is a positive int, so tile_size=17 slips through and writes a file that the in-repo reader round-trips fine but that strict TIFF readers (GDAL, libtiff strict mode) may reject.
Reproducer:
import numpy as np
import xarray as xr
from xrspatial.geotiff import to_geotiff
da = xr.DataArray(np.zeros((32, 32), dtype="float32"), dims=("y", "x"))
to_geotiff(da, "/tmp/bad.tif", tiled=True, tile_size=17) # writes anyway
Fix: when tiled=True, require tile_size to be a positive multiple of 16. Raise ValueError naming the bad value and suggesting the nearest valid choices ((tile_size // 16) * 16 and ((tile_size // 16) + 1) * 16). Update the docstring.
to_geotiffacceptstile_sizevalues that violate the TIFF 6 spec.The spec requires TileWidth and TileLength to be multiples of 16. The current validation in
xrspatial/geotiff/__init__.pyonly checks thattile_sizeis a positive int, sotile_size=17slips through and writes a file that the in-repo reader round-trips fine but that strict TIFF readers (GDAL, libtiff strict mode) may reject.Reproducer:
Fix: when
tiled=True, requiretile_sizeto be a positive multiple of 16. RaiseValueErrornaming the bad value and suggesting the nearest valid choices ((tile_size // 16) * 16and((tile_size // 16) + 1) * 16). Update the docstring.