Stackstac.stack rescaling and landsat-c2-l2 #119
Replies: 3 comments
|
Mmm, I'm not 100% what IIUC, that's actually getting the scales and offsets from actual data assets (COGs in this case) not the STAC metadata. That's based off https://github.com/gjoseph92/stackstac/blob/9106708bcc20daec4c5975e9c1240de38c38f2f1/stackstac/rio_reader.py#L98. import rasterio
import pystac
import planetary_computer
item = pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC08_L2SR_085082_20220323_02_T2")
ds = rasterio.open(planetary_computer.sign(item.assets["blue"].href))
print("STAC:", item.assets["blue"].extra_fields["raster:bands"][0])
print(" COG:", ds.scales, ds.offsets)prints out IIUC, these values are coming from the stactools source: https://github.com/stactools-packages/landsat/blob/5cfff89ab39030aef6c1dc5c818453469963cd76/src/stactools/landsat/fragments/collections/landsat-c2-l2.json#L372-L380 So I would have two questions:
|
|
Ok, looks like the USGS COGs are the issue. I will scale manually. |
|
FYI, stackstac also wasn't always handling the scale and offset fields set on COGs correctly, but that's been fixed in gjoseph92/stackstac#183 (but not yet released). Also, stackstac doesn't look at So short answer is that unless scale and offset are set correctly on the COG, you'll have to rescale manually for now. |
Uh oh!
There was an error while loading. Please reload this page.
The stackstac.stack rescale option doesn't seem to work for landsat-c2-l2, e.g.
Gives a value of 3205. I see the correct scale and offset values in the collection metadata. Do I need to perform the calculations myself?
I can ask on the stackstac issues page too, just not sure whose issue this is.
All reactions