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

Proposed change: have stack_bands() return xarray.Dataset with common band names #32

Open
scottyhq opened this issue Dec 6, 2019 · 1 comment
Labels
discussion enhancement New feature or request

Comments

@scottyhq
Copy link
Collaborator

scottyhq commented Dec 6, 2019

@jsignell did some awesome work putting together the stack_bands() in #19

I'd like to propose a few modifications (building off examples/planet_disaster_data.ipynb) and can follow up with a pull request:

  1. 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'
  1. 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>
@jhamman
Copy link
Collaborator

jhamman commented Dec 6, 2019

@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.

@jhamman jhamman added the enhancement New feature or request label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants