import rasterio img=rasterio.open('my_raster.tif') profile = img.profile profile.update(dtype=rasterio.uint8,count=1,nodata=42, compress='lzw')