write
write#
- write(xds: Union[xarray.core.dataset.Dataset, xarray.core.dataarray.DataArray], path: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], **kwargs) None [source]#
Write raster to disk. (encapsulation of
rasterio
’s function, because for nowrioxarray
to_raster doesn’t work as expected)Metadata will be created with the
xarray
metadata (ie. width, height, count, type…) The driver isGTiff
by default, and no nodata value is provided. The file will be compressed if the raster is a mask (saved as uint8).If not overwritten, sets the nodata according to
dtype
:uint8: 255
int8: -128
uint16, uint32, int32, int64, uint64: 65535
int16, float32, float64, float128, float: -9999
Compress with
LZW
option by default. To disable it, add thecompress=None
parameter.- Parameters
xds (XDS_TYPE) – Path to the raster or a rasterio dataset or a xarray
path (Union[str, CloudPath, Path]) – Path where to save it (directories should be existing)
**kwargs – Overloading metadata, ie
nodata=255
ordtype=np.uint8