Skip to content

to_xarray download fallback #104

@guillaumeeb

Description

@guillaumeeb

Is your feature request related to a problem? Please describe.
Using to_xarray on an example from CNES S3 Datalake seems to trigger concurrent downloading of data:

Image

This is lasting for about a minute, and generates high memory spikes (more than GiB temporarily for an entire product).

Describe the solution you'd like
to_xarray should not load the data. open_rasterio from rioxarray only needs to read the metadata of the rasters to create the xarray structure. Plus, the ipywidget in a Jupyter env seems to indicate some temporary download?

Describe alternatives you've considered
Use directly rioXarray, e.g.

import rioxarray as rxr
import xarray as xr

with env:
    xr_da_b2 = rxr.open_rasterio(product.assets["B02"]["href"]).squeeze() # remove band dimension
    xr_da_b3 = rxr.open_rasterio(product.assets["B03"]["href"]).squeeze()
    xr_da_b4 = rxr.open_rasterio(product.assets["B04"]["href"]).squeeze()
    xr_da_b8 = rxr.open_rasterio(product.assets["B08"]["href"]).squeeze()
    xr_ds = xr.Dataset(data_vars={'blue':xr_da_b2, 'green':xr_da_b3, 'red':xr_da_b4, 'nir': xr_da_b8})
xr_ds

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions