Skip to content

Commit

Permalink
formatted and docstring update
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoelles committed Jun 4, 2024
1 parent 3e28334 commit 498d930
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
DEFAULT_NO_DATA_VALUE = -9999
SUPPORTED_FILE_FORMATS = [".tif", ".tiff"]


class GeotiffDataset(AbstractVersionedDataset[xarray.DataArray, xarray.DataArray]):
"""``GeotiffDataset`` loads and saves rasterdata files and reads them as xarray
DataArrays. The underlying functionality is supported by rioxarray, rasterio and xarray.
Reading and writing of single and multiband geotiffs data is supported. There are sanity checks to
ensure that a coordinate reference system (CRS) is present.
Reading and writing of single and multiband geotiffs data is supported. There are sanity checks to ensure that a coordinate reference system (CRS) is present.
Arbitrary xarray.DataArray objects can not be saved to a geotiff file. Have a look at netcdf if this is what you need.
Expand Down Expand Up @@ -73,7 +73,6 @@ def __init__( # noqa: PLR0913
load_args: dict[str, Any] | None = None,
save_args: dict[str, Any] | None = None,
version: Version | None = None,
fs_args: dict[str, Any] | None = None,
metadata: dict[str, Any] | None = None,
):
"""Creates a new instance of ``GeotiffDataset`` pointing to a concrete
Expand All @@ -87,9 +86,7 @@ def __init__( # noqa: PLR0913
Here you can find all available arguments:
https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray-open-rasterio
All defaults are preserved.
save_args: rioxarray options for saving to a geotiff file.
Here you can find all available arguments:
https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray.raster_dataset.GeotiffDataset.to_raster
save_args: options for rioxarray for data without the band dimension and rasterio otherwhise.
version: If specified, should be an instance of
``kedro.io.core.Version``. If its ``load`` attribute is
None, the latest version will be loaded. If its ``save``
Expand Down Expand Up @@ -163,7 +160,6 @@ def _invalidate_cache(self) -> None:
filepath = get_filepath_str(self._filepath, self._protocol)
self._fs.invalidate_cache(filepath)


def _save_multiband(self, data: xarray.DataArray, save_path: str):
"""Saving multiband raster data to a geotiff file."""
bands_data = [data.sel(band=band) for band in data.band.values]
Expand All @@ -176,7 +172,9 @@ def _save_multiband(self, data: xarray.DataArray, save_path: str):
height=data[0].shape[0],
)

nodata_value = data.rio.nodata if data.rio.nodata is not None else DEFAULT_NO_DATA_VALUE
nodata_value = (
data.rio.nodata if data.rio.nodata is not None else DEFAULT_NO_DATA_VALUE
)
crs = data.rio.crs

meta = {
Expand Down

0 comments on commit 498d930

Please sign in to comment.