- imod.formats.rasterio.save(path, a, driver=None, nodata=nan, pattern=None, dtype=None)#
Write a xarray.DataArray to one or more rasterio supported files
If the DataArray only has
xdimensions, a single raster file is written, like the
imod.rasterio.writefunction. This function is more general and also supports
layerand other dimensions. It will split these up, give them their own filename according to the conventions in
imod.util.compose, and write them each.
path (str or Path) – Path to the raster file to be written. This function decides on the actual filename(s) using conventions, so it only takes the directory and name from this parameter.
a (xarray.DataArray) – DataArray to be written. It needs to have dimensions (‘y’, ‘x’), and optionally
driver (str, optional) – Which GDAL format driver to use. The complete list is at https://gdal.org/drivers/raster/index.html. By default tries to guess from the file extension.
nodata (float, optional) – Nodata value in the saved raster files. Defaults to a value of nan.
pattern (str) – Format string which defines how to create the filenames. See examples.
Consider a DataArray
dathat has dimensions ‘layer’, ‘y’ and ‘x’, with the ‘layer’ dimension consisting of layer 1 and 2:
This writes the following two tif files: ‘path/to/head_l1.tif’ and ‘path/to/head_l2.tif’.
It is possible to generate custom filenames using a format string. The default filenames would be generated by the following format string:
If you desire zero-padded numbers that show up neatly sorted in a file manager, you may specify:
In this case, a 0 will be padded for single digit numbers (‘1’ will become ‘01’).
To get a date with dashes, use the following pattern: