Skip to content

Commit

Permalink
Incremental commit on accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Nov 20, 2024
1 parent f680eaa commit 886884e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions geoutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from geoutils import examples, projtools, raster, vector # noqa
from geoutils._config import config # noqa
from geoutils.raster import Mask, Raster, SatelliteImage, rst_accessor # noqa
from geoutils.raster.rst_accessor import open_raster # noqa
from geoutils.raster import Mask, Raster, SatelliteImage, xr_accessor # noqa
from geoutils.raster.xr_accessor import open_raster # noqa
from geoutils.vector import Vector # noqa

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def open_raster(filename: str, **kwargs):

@xr.register_dataarray_accessor("rst")
class RasterAccessor(RasterBase):
"""
This class defines the Xarray accessor 'rst' for rasters.
Most attributes and functionalities are inherited from the RasterBase class (also parent of the Raster class).
Only methods specific to the functioning of the Xarray accessor live in this class: mostly initialization, I/O or
copying.
"""
def __init__(self, xarray_obj: xr.DataArray):

super().__init__()
Expand Down Expand Up @@ -85,18 +92,11 @@ def from_array(

return out_ds



def to_raster(self) -> RasterBase:
"""
Convert to Raster object.
# TODO: Rioxarray uses "to_raster" to write to file... Change naming?
:return:
"""
return gu.Raster.from_array(data=self._obj.data, crs=self.crs, transform=self.transform, nodata=self.nodata)


@xr.register_dataarray_accessor("sat")
class SatelliteImageAccessor(RasterAccessor):
def __init__(self, xarray_obj: xr.DataArray):
self._obj = xarray_obj
File renamed without changes.

0 comments on commit 886884e

Please sign in to comment.