-
Notifications
You must be signed in to change notification settings - Fork 20
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
Can't read all bands from multi band visual asset from "sentinel-2-c1-l2a" collection #148
Comments
@rbavery what version of |
Ok, so it's missing Visual band should have this extra info: {"assets": {"visual": {
...,
"raster:bands": [{"data_type": "uint8"},{"data_type": "uint8"},{"data_type": "uint8"}]
}}} Sample item: https://earth-search.aws.element84.com/v1/collections/sentinel-2-c1-l2a/items/S2B_T52JFM_20240407T012410_L2A ping @gadomski, Appendix{"assets": {
"visual": {
"href": "https://e84-earth-search-sentinel-data.s3.us-west-2.amazonaws.com/sentinel-2-c1-l2a/52/J/FM/2024/4/S2B_T52JFM_20240407T012410_L2A/TCI.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"title": "True color image",
"eo:bands": [
{
"name": "B04",
"common_name": "red",
"center_wavelength": 0.665,
"full_width_half_max": 0.038
},
{
"name": "B03",
"common_name": "green",
"center_wavelength": 0.56,
"full_width_half_max": 0.045
},
{
"name": "B02",
"common_name": "blue",
"center_wavelength": 0.49,
"full_width_half_max": 0.098
}
],
"gsd": 10,
"proj:shape": [
10980,
10980
],
"proj:transform": [
10,
0,
600000,
0,
-10,
6700000
],
"file:checksum": "1220cb7e18f0fb190115e61d9c04adcebf2a98d6d786a9e01360d0fafaac6db6c36e",
"file:size": 304120956,
"roles": [
"visual"
]
}
}} |
@Kirill888 I checked with @matthewhanson and it sound like |
Got it thanks for the investigation and info @Kirill888 and @gadomski. It's pretty common in the ML community to select less precise data types to optimize for storage and throughput. Not all detection tasks require the full precision of the analysis assets. For example this SATLAS model I'm working with was trained on and expects to test on the TCI visual product: https://github.com/allenai/satlas/blob/main/Normalization.md#sentinel-2-images It'd definitely be helpful to have the raster:bands metadata. Currently I'm working with the float bands instead to get around this and need to stack these bands myself. I'm also not sure if I'm doing normalization exactly like the TCI product has done. |
@rbavery it's a bit hacky, but you to get this working you can just create the metadata yourself for the visual asset, then loop through your items and insert it into the JSON. Then open it with odc-stac. |
|
@gadomski @matthewhanson I would have thought that It's always easier to ignore "loadable data" than to make "unloadable data" work from the end-user perspective. It's not like lack of Also
|
just a heads up that this doesn't work since assets don't support item assignment for item in items:
item.assets['visual']['raster:bands'] = [
{'nodata': 0, 'data_type': 'uint8'},
{'nodata': 0, 'data_type': 'uint8'},
{'nodata': 0, 'data_type': 'uint8'}
]
And odc.stac requires working with the pystac objects that have stac metadata as attributes, so converting the item collection to an iterable of dicts won't work. |
Yeah @rbavery, pystac's extensions are getting in your way here. The assigment should be: from pystac.extensions.raster import RasterBand
item.assets["visual"].ext.raster.bands = [
RasterBand.create(nodata=0, data_type="uint8"),
RasterBand.create(nodata=0, data_type="uint8"),
RasterBand.create(nodata=0, data_type="uint8"),
] Full test scriptimport json
from pystac_client import Client
from pystac.extensions.raster import RasterBand
client = Client.open("https://earth-search.aws.element84.com/v1/")
item_search = client.search(
max_items=1,
collections=["sentinel-2-c1-l2a"],
intersects={"type": "point", "coordinates": [-115.3479, 51.0884]},
sortby="-properties.datetime",
)
item = next(item_search.items())
item.assets["visual"].ext.raster.bands = [
RasterBand.create(nodata=0, data_type="uint8"),
RasterBand.create(nodata=0, data_type="uint8"),
RasterBand.create(nodata=0, data_type="uint8"),
]
print(json.dumps(item.assets["visual"].to_dict())) |
Thank you! makes sense |
I'm trying to read a multi band asset following the guidance here: #118 (comment)
but this errors, the visual asset's multiple bands are not found. only "visual.1" is found.
If I change the load to
the asset is found but I can only get the first band.
My odc stac version is v0.3.9.
I can provide a MRE if it is helpful for diagnosing the issue but first wanted to check if I'm specifying the bands incorrectly.
The text was updated successfully, but these errors were encountered: