Skip to content

Commit

Permalink
Merge pull request pytroll#2824 from ludwigVonKoopa/rioxarray_imports
Browse files Browse the repository at this point in the history
add import rioxarray where readers actually need them
  • Loading branch information
djhoese authored Jun 19, 2024
2 parents 394add5 + 76e6b82 commit 90d36d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ avhrr_l1b_gaclac = ["pygac >= 1.3.0"]
modis_l1b = ["pyhdf", "python-geotiepoints >= 1.1.7"]
geocat = ["pyhdf"]
goci2 = ["netCDF4 >= 1.1.8"]
generic_image = ["rasterio", "rioxarray"]
acspo = ["netCDF4 >= 1.1.8"]
clavrx = ["netCDF4 >= 1.1.8"]
viirs_l1b = ["netCDF4 >= 1.1.8"]
Expand Down
4 changes: 4 additions & 0 deletions satpy/readers/generic_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import dask.array as da
import numpy as np
import rasterio
import rioxarray # noqa: F401 # need by xarray with the engine rasterio
import xarray as xr
from pyresample import utils

Expand Down Expand Up @@ -76,6 +77,9 @@ def read(self):
if hasattr(dataset, "crs") and dataset.crs is not None:
self.area = utils.get_area_def_from_raster(dataset)

# xarray use the engine 'rasterio' to open the file, but
# its actually rioxarray used in the backend.
# however, error is not explicit enough (see https://github.com/pydata/xarray/issues/7831)
data = xr.open_dataset(self.finfo["filename"], engine="rasterio",
chunks={"band": 1, "y": CHUNK_SIZE, "x": CHUNK_SIZE}, mask_and_scale=False)["band_data"]
if hasattr(dataset, "nodatavals"):
Expand Down
1 change: 1 addition & 0 deletions satpy/readers/sar_c_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import defusedxml.ElementTree as ET
import numpy as np
import rasterio
import rioxarray # noqa F401 # xarray open_dataset use engine rasterio, which use rioxarray
import xarray as xr
from dask import array as da
from geotiepoints.geointerpolator import lonlat2xyz, xyz2lonlat
Expand Down

0 comments on commit 90d36d1

Please sign in to comment.