intake-stac
intake-stac copied to clipboard
Proposed change: have stack_bands() return xarray.Dataset with common band names
@jsignell did some awesome work putting together the stack_bands() in https://github.com/pangeo-data/intake-stac/pull/19
I'd like to propose a few modifications (building off examples/planet_disaster_data.ipynb) and can follow up with a pull request:
- Return common_name labels if they are used to select bands (notice 'B4' and 'B5') in DataArray
landsat['LC80110312014230LGN00'].stack_bands(['red', 'nir']).to_dask()
<xarray.DataArray (band: 2, y: 7941, x: 7811)>
dask.array<concatenate, shape=(2, 7941, 7811), dtype=uint16, chunksize=(1, 7941, 7811), chunktype=numpy.ndarray>
Coordinates:
* y (y) float64 4.742e+06 4.742e+06 4.742e+06 ... 4.504e+06 4.504e+06
* x (x) float64 3.183e+05 3.183e+05 3.184e+05 ... 5.526e+05 5.526e+05
* band (band) <U2 'B4' 'B5'
- Return an xarray DataSet instead of DataArray by default (
da.to_dataset(dim='band')), so we end up with this:
<xarray.Dataset>
Dimensions: (x: 7811, y: 7941)
Coordinates:
* y (y) float64 4.742e+06 4.742e+06 4.742e+06 ... 4.504e+06 4.504e+06
* x (x) float64 3.183e+05 3.183e+05 3.184e+05 ... 5.526e+05 5.526e+05
Data variables:
red (y, x) uint16 dask.array<chunksize=(7941, 7811), meta=np.ndarray>
nir (y, x) uint16 dask.array<chunksize=(7941, 7811), meta=np.ndarray>
@scottyhq - these sound like reasonable propositions. I'm not up to speed on STAC's use of common_name labels but this does sound like a useful feature to add. On the subject of returning a dataset vs. dataarray, I think there are going to be advantages to both approaches. I think its worth prototyping both of these so a PR sounds like a good idea.