stactools-packages / browse

stactools package for opening a STAC catalog with stac-browser
Other
0 stars 2 forks source link

Allow more customization of 'stac browse' command #1

Open gadomski opened 3 years ago

gadomski commented 3 years ago

From @scottyhq

In working on implementing a Sentinel-1 subpackage I came across an issue with the current implementation of stac browse which is limited to RGB assets it seems, leading to log errors like JPEG driver doesn't support data type UInt16. Only eight bit byte bands supported. described in more detail here https://github.com/stac-utils/stactools/pull/84#issuecomment-812360604

I spent some time familiarizing with how stac browse is using titiler behind the scenes, with configuration here: https://github.com/stac-utils/stactools/blob/8815b1451dad6fd7bb2caa3729a20f1476ab8f92/stactools_browse/stactools/browse/docker-compose.yml.template#L44

S1 assets are single-band dtype Uint16 or Float32, so a client has to specify a rescale parameter https://api.cogeo.xyz/cog/tiles/8/38/88?url=https://sentinel-s1-rtc-indigo.s3.us-west-2.amazonaws.com/tiles/RTC/1/IW/10/U/CU/2017/S1A_20170101_10UCU_ASC/Gamma0_VV.tif&rescale=0,0.5

It would be great for stac browse to support all the endpoint parameters. In particular rescaling with expressions is extremely useful for SAR (for example converting power -> amplitude -> dB to modify dynamic range for visualizations) https://api.cogeo.xyz/cog/preview?url=https://sentinel-s1-rtc-indigo.s3.us-west-2.amazonaws.com/tiles/RTC/1/IW/10/U/CU/2017/S1A_20170101_10UCU_ASC/Gamma0_VV.tif&expression=sqrt(b1)&rescale=0,1

What would be particularly nice would be to use the titiler /stac endpoint instead of /cog to extract default expressions and rescale ranges that could be stored in the metadata. cc @vincentsarago

From @cholmes

What would be particularly nice would be to use the titiler /stac endpoint instead of /cog to extract default expressions and rescale ranges that could be stored in the metadata. cc

Yes, it does seem like if there is one tool that should use the /stac endpoint it's probably 'stac browse' ;) To be fair I think the titiler /stac endpoint may have come after stac browse was written, but I agree it'd be a great enhancement.

Migration

Migrated from https://github.com/stac-utils/stactools/issues/86.

vincentsarago commented 3 years ago

FYI: @gadomski we've updated rio-tiler/titiler couple weeks ago to remove the not supported datatype error. Now rio-tiler should rescale the data using the datatype min/max bounds (thus return black images).

The /stac endpoints use the STACReader from rio-tiler (https://cogeotiff.github.io/rio-tiler/readers/#stacreader) which is pretty basic and do not use other metadata than the asset href. To use default rescaling or expression (not part of any specs) you'll need to create either your own Reader (subclassing STACReader) or custom endpoints.