stackstac icon indicating copy to clipboard operation
stackstac copied to clipboard

Use `data_type` and `nodata` from `raster` extension if present

Open TomAugspurger opened this issue 4 years ago • 3 comments

Currently the default dtype is float64 and the default fill_value is np.nan.

The raster extension defines fields for specifying the dtype (data_type) and fill value (no_data). It might be a good idea to change the default to using values from raster:band, falling back to float64 / np.nan if the raster extension isn't present.

TomAugspurger avatar Nov 27 '21 17:11 TomAugspurger

Thanks for opening the issue to track this; there's some more info in https://github.com/gjoseph92/stackstac/issues/63#issuecomment-868726296 too. Definitely excited about the raster extension! @TomAugspurger think you'd have any time to work on this?

gjoseph92 avatar Nov 29 '21 16:11 gjoseph92

Thanks for the link to #63.

We're going to standardize our use of the raster extension in our STAC API over the couple months. Once that work is started I'll be happy to work on this. I just wanted to make sure there was agreement with the API change (to use information from raster:bands) before starting on that.

TomAugspurger avatar Nov 29 '21 16:11 TomAugspurger

Awesome, happy to hear raster:bands is going to get some traction!

Note that in doing this, we'll probably want to add some special-handling logic for raster:bands, similar to how the subfields of eo:bands get pulled out into top-level coordinates (I could also see making this more generic to any dict-ish fields in flattened_metadata_by_asset): https://github.com/gjoseph92/stackstac/blob/3a58906ed6a6ab39205d91b4665f595644b22ce9/stackstac/prepare.py#L485-L518

gjoseph92 avatar Nov 29 '21 17:11 gjoseph92