hydromt.model.components.SpatialDatasetsComponent.write#

SpatialDatasetsComponent.write(filename: str | None = None, gdal_compliant: bool = False, rename_dims: bool = False, force_sn: bool = False, **kwargs) None[source]#

Write dictionary of xarray.Dataset and/or xarray.DataArray to netcdf files.

Possibility to update the xarray objects attributes to get GDAL compliant NetCDF files, using gdal_compliant(). The function will first try to directly write to file. In case of PermissionError, it will first write a temporary file and add to the self._defered_file_closes attribute. Renaming and closing of netcdf filehandles will be done by calling the self._cleanup function.

key-word arguments are passed to xarray.Dataset.to_netcdf()

Parameters:
  • nc_dict (dict) – Dictionary of xarray.Dataset and/or xarray.DataArray to write

  • fn (str) – filename relative to model root and should contain a {name} placeholder

  • gdal_compliant (bool, optional) – If True, convert xarray.Dataset and/or xarray.DataArray to gdal compliant format using gdal_compliant()

  • rename_dims (bool, optional) – If True, rename x_dim and y_dim to standard names depending on the CRS (x/y for projected and lat/lon for geographic). Only used if gdal_compliant is set to True. By default, False.

  • force_sn (bool, optional) – If True, forces the dataset to have South -> North orientation. Only used if gdal_compliant is set to True. By default, False.

  • **kwargs – Additional keyword arguments that are passed to the to_netcdf function.