Skip to content

Clarification about the right use of DataArray and Dataset #6748

Answered by scottyhq
MaxDragonheart asked this question in Q&A
Discussion options

You must be logged in to vote

@MaxDragonheart it's a matter of preference to use the DataArray or DataSet representation with bands as variables. Xarray allows you to move back and forth with to_dataset() and to_array() methods.

Just be careful that the CRS (spatial_ref) of your DataArrays match as Xarray will not automatically reproject data in different CRS when constructing a cube. You might check out this example notebook for a DataSet representation https://planetarycomputer.microsoft.com/dataset/landsat-c2-l2#Example-Notebook:

There are so many ways to get Landsat data these days, where are you obtaining it from? Libraries that build on Xarray like stackstac or odc-stac make constructing DataSets easy and will …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MaxDragonheart
Comment options

Answer selected by dcherian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants