Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to_xarray methods to Asset and EOProduct #78

Open
4 tasks done
amarandon opened this issue Dec 4, 2024 · 1 comment · May be fixed by #79
Open
4 tasks done

Add to_xarray methods to Asset and EOProduct #78

amarandon opened this issue Dec 4, 2024 · 1 comment · May be fixed by #79
Assignees
Labels
enhancement New feature or request

Comments

@amarandon
Copy link
Collaborator

amarandon commented Dec 4, 2024

  • Create Asset.to_xarray() -> xarray.Dataset with kwargs forwarded to xarray.open_dataset. It will re-use get_data code, without clip / reproject features. Pass auth information through backend_kwargs parameter, that will be sent to fsspec
  • Create EOProduct.to_xarray() -> XarrayDict, where XarrayDict is a UserDict[str, xarray.Dataset], also forwarding kwargs to xarray.open_dataset
  • add _repr_html_ method to XarrayDict
XarrayDict (5)
--------------
> B01 : xarray.Dataset (band:1, x: 1000, y: 1000)
> B02 : xarray.Dataset (band:1, x: 500, y: 500)
> B03 : xarray.Dataset (band:1, x: 1000, y: 1000)
> B04 : xarray.Dataset (band:1, x: 1000, y: 1000)
> B05 : xarray.Dataset (band:1, x: 2000, y: 2000)
  • deprecate get_data and show how to clip / reproject in a tutorial
ds.rio.clip([search_results[0].search_intersection.__geo_interface__], "EPSG:4326")
@amarandon
Copy link
Collaborator Author

amarandon commented Dec 6, 2024

@sbrunato I've pushed requested changes. However when I test the method Asset.to_xarray implemented according to your requirements, it fails with this error:

OSError: [Errno -90] NetCDF: file not found:
'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/60/V/UL/2020/6/S2A_60VUL_20200604_0_L2A/AOT.tif

Any idea?

My test code:

from eodag import EODataAccessGateway

dag = EODataAccessGateway()
product_type = 'S2_MSI_L2A_COG'
start, end = '2020-06-04', '2020-06-05'
search_results = dag.search(productType=product_type, start=start, end=end)
product = search_results[0]
asset = product.assets['aot']
ds = asset.to_xarray()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant