Skip to content

Commit

Permalink
Remove optional import for rioxarray (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet authored Mar 13, 2024
1 parent 17ea17a commit 4e1c6f4
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import rasterio as rio
import rasterio.warp
import rasterio.windows
import rioxarray
import xarray as xr
from affine import Affine
from mpl_toolkits.axes_grid1 import make_axes_locatable
from rasterio.crs import CRS
Expand Down Expand Up @@ -54,15 +56,6 @@
except ImportError:
from typing_extensions import Literal # type: ignore

try:
import rioxarray
import xarray as xr

_has_rioxarray = True
except ImportError:
rioxarray = None
_has_rioxarray = False

RasterType = TypeVar("RasterType", bound="Raster")

# List of NumPy "array" functions that are handled.
Expand Down Expand Up @@ -2650,8 +2643,6 @@ def to_xarray(self, name: str | None = None) -> xr.DataArray:
:returns: xarray DataArray
"""
if not _has_rioxarray:
raise ImportError("rioxarray is required for this functionality.")

ds = rioxarray.open_rasterio(self.to_rio_dataset())
if name is not None:
Expand Down

0 comments on commit 4e1c6f4

Please sign in to comment.