Re: a_scale parameter for writing GTiff file

Sean Gillies


On Fri, Apr 8, 2022 at 6:58 AM calba via <> wrote:

I'm trying to transform the dtype of my input raster from float32 to int16 (I'm using dask, dask-rasterio and rasterio). So I multiplied the data in my matrix by 100 and convert the dtype of my dask array to rasterio.int16. 
def multiply(array):
multipliedArray = np.where(array >= 14, 100*array, -9999)
multipliedDaskArray = da.from_array(multipliedArray, chunks=(1, 5, 365))
multipliedDaskArray.dtype = rasterio.int16
return multipliedDaskArray

Now, I want to write a new GTiff file with scale 0.01 using and the equivalent in rasterio of the a_scale parameter from gdal_translate function. But I don't find this equivalent yet.

After numerous tests and researches, I still haven't found the a_scale option in rasterio... So can someone explain to me if this is possible ? And if so, how ?

Thank you in advance :)

Rasterio has no option to scale on opening or on reading. It's my understanding that gdal_translate's -a_scale sets a scaling metadata value but that I/O methods like do not apply the scaling automatically. It is up to the caller to perform the scaling.

Sean Gillies

Join to automatically receive all group messages.