stac-browser
stac-browser copied to clipboard
Inversion of image outside of BBOX in STAC Browser
Issue
I currently have an collection uploaded to STAC Browser FastAPI here. The collection and corresponding items have been validated and show to work correctly and even loads into an xArray object using odc-stac. However, on STAC Browser, the visualization of the image is inverted outside of the bounding box, see sample images below. What do you suggest might be the cause of this inversion?
What the Original Collection looks like:
{
"type": "Collection",
"id": "CERRA_2m_temperature_2001",
"stac_version": "1.0.0",
"description": "The Copernicus European Regional ReAnalysis (CERRA) datasets provide spatially and temporally consistent historical reconstructions of meteorological variables in the atmosphere and at the surface. ",
"links": [
{
"rel": "items",
"href": "https://stac.eurac.edu/collection/CERRA_2m_temperature_2001/items",
"type": "application/json"
},
{
"rel": "parent",
"href": "https://stac.eurac.edu",
"type": "application/json"
},
{
"rel": "self",
"href": "https://stac.eurac.edu/collection/CERRA_2m_temperature_2001",
"type": "application/json"
},
{
"rel": "root",
"href": "https://stac.eurac.edu",
"type": "application/json"
},
{
"rel": "license",
"href": "https://cds.climate.copernicus.eu/api/v2/terms/static/licence-to-use-copernicus-products.pdf",
"title": "License to use Copernicus Products"
}
],
"keywords": [
"intertwin",
"temperature",
"cerra",
"climate"
],
"providers": [
{
"url": "https://cds.climate.copernicus.eu/cdsapp#!/dataset/10.24381/cds.622a565a",
"name": "Copernicus",
"roles": [
"producer",
"licensor"
]
},
{
"url": "http://www.eurac.edu",
"name": "Eurac EO",
"roles": [
"host"
]
}
],
"title": "CERRA sub-daily regional reanalysis data for the European Alps on single levels",
"sci:citation": "Schimanke S., Ridal M., Le Moigne P., Berggren L., Und\u00e9n P., Randriamampianina R., Andrea U., Bazile E., Bertelsen A., Brousseau P., Dahlgren P., Edvinsson L., El Said A., Glinton M., Hopsch S., Isaksson L., Mladek R., Olsson E., Verrelle A., Wang Z.Q., (2021): CERRA sub-daily regional reanalysis data for Europe on single levels from 1984 to present. Copernicus Climate Change Service (C3S) Climate Data Store (CDS), DOI: 10.24381/cds.622a565a (Accessed on 15-02-2024)",
"sci:doi": "https://doi.org/10.24381/cds.622a565a",
"summaries": {
"eo:bands": [
{
"name": "t2m"
}
]
},
"stac_extensions": [
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/raster/v1.1.0/schema.json",
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/scientific/v1.0.0/schema.json"
],
"cube:dimensions": {
"longitude": {
"axis": "x",
"type": "spatial",
"extent": [
5.084033,
15.958283
],
"reference_system": 4326
},
"latitude": {
"axis": "y",
"type": "spatial",
"extent": [
43.553066,
50.064191
],
"reference_system": 4326
},
"time": {
"type": "temporal",
"extent": [
"2001-01-01T00:00:00.000000000",
"2001-12-31T00:00:00.000000000"
]
},
"bands": {
"type": "bands",
"values": [
"t2m"
]
}
},
"extent": {
"spatial": {
"bbox": [
[
5.050470499999999,
43.5195035,
15.9918455,
50.097753499999996
]
]
},
"temporal": {
"interval": [
[
"2001-01-01T00:00:00Z",
"2001-12-31T00:00:00Z"
]
]
}
},
"license": "proprietary"
}
A sample item
{
"type": "Feature",
"stac_version": "1.0.0",
"id": "20010101000000",
"properties": {
"datetime": "2001-01-01T00:00:00Z"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
5.050470499999999,
43.5195035
],
[
15.9918455,
43.5195035
],
[
15.9918455,
50.097753499999996
],
[
5.050470499999999,
50.097753499999996
],
[
5.050470499999999,
43.5195035
]
]
]
},
"links": [
{
"rel": "collection",
"href": "https://stac.eurac.edu/collection/CERRA_2m_temperature_2001",
"type": "application/json"
},
{
"rel": "parent",
"href": "https://stac.eurac.edu/collection/CERRA_2m_temperature_2001",
"type": "application/json"
},
{
"rel": "self",
"href": "https://stac.eurac.edu/collection/CERRA_2m_temperature_2001/20010101000000",
"type": "application/json"
},
{
"rel": "root",
"href": "https://stac.eurac.edu",
"type": "application/json"
}
],
"assets": {
"t2m": {
"href": "https://eurac-eo.s3-eu-west-1.amazonaws.com/INTERTWIN/CERRA/t2m_20010101000000.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"proj:epsg": 4326,
"proj:geometry": {
"type": "Polygon",
"coordinates": [
[
[
5.050470499999999,
50.097753499999996
],
[
15.9918455,
50.097753499999996
],
[
15.9918455,
43.5195035
],
[
5.050470499999999,
43.5195035
],
[
5.050470499999999,
50.097753499999996
]
]
]
},
"proj:bbox": [
5.050470499999999,
50.097753499999996,
15.9918455,
43.5195035
],
"proj:shape": [
98,
163
],
"proj:transform": [
0.067125,
0.0,
5.050470499999999,
0.0,
0.067125,
43.5195035,
0.0,
0.0,
1.0
],
"proj:projjson": {
"$schema": "https://proj.org/schemas/v0.4/projjson.schema.json",
"type": "GeographicCRS",
"name": "WGS 84",
"datum": {
"type": "GeodeticReferenceFrame",
"name": "World Geodetic System 1984",
"ellipsoid": {
"name": "WGS 84",
"semi_major_axis": 6378137,
"inverse_flattening": 298.257223563
}
},
"coordinate_system": {
"subtype": "ellipsoidal",
"axis": [
{
"name": "Geodetic latitude",
"abbreviation": "Lat",
"direction": "north",
"unit": "degree"
},
{
"name": "Geodetic longitude",
"abbreviation": "Lon",
"direction": "east",
"unit": "degree"
}
]
},
"id": {
"authority": "EPSG",
"code": 4326
}
},
"raster:bands": [
{
"data_type": "float32",
"scale": 1.0,
"offset": 0.0,
"sampling": "area",
"statistics": {
"mean": -1.6650447845458984,
"minimum": -21.023025512695312,
"maximum": 12.350738525390625,
"stddev": 5.345924377441406,
"valid_percent": 0.00626017278076875
},
"histogram": {
"count": 11,
"min": -21.023025512695312,
"max": 12.350738525390625,
"buckets": [
31,
128,
393,
1122,
3747,
3297,
3837,
1985,
833,
601
]
}
}
],
"eo:bands": [
{
"name": "t2m"
}
]
}
},
"bbox": [
5.050470499999999,
43.5195035,
15.9918455,
50.097753499999996
],
"stac_extensions": [
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/raster/v1.1.0/schema.json",
"https://stac-extensions.github.io/eo/v1.1.0/schema.json"
],
"collection": "CERRA_2m_temperature_2001"
}
Possible cause
It seems this might be due to an inversion of the coords in the transformation matrix (especially in the Y axis)
A sample image
@m-mohr It might be related to this: https://github.com/geotiffjs/geotiff.js/pull/337
Yes, might be. The first check should be whether the latest version of geotiff.js is used. I don't have th capacity to check this right now, but the fix must either be made in stac-layer or in geotiff.js anyway. Did you check whether this works correctly with ol-stac?
I've a similar but slightly different issue you can have a screenshot below where the image is translated and scaled not only flipped:
The image in the red circle
in a zoom is better visible the image:
The images is locally served, I double checked that stac item is correctly set in it's geometry and BBOX and it is correctly shown in QGIS or titiler viewer
I debugged vue stac-browser app and realised that StacLayer return a wrong BBOX in Map.vue that seems leading to the wrong transformation and scaling.
here the stac Item befor importin in the stac catalog 6018-lvl02-color.json.updated.json
and here the image (linked because if big) that I serve locally
note: checking with ol-stac if the issue is still present
Seems ol-stac read correctly the extension but not do a correct render:
Yes, that's also what I'm seing.
- geotiff.js seems fine for now.
- ol-stac seems to have issue rendering the bands correctly.
- stac-layer seems to use a very outdated geotiff.js version and (through georaster-layer-for-leaflet, see https://github.com/GeoTIFF/georaster-layer-for-leaflet/issues) uses potentially a different projection methodology compared to ol-stac. So the issue might be sitting there, we had issues with it in the past.
Generally, the aim is to migrate to ol-stac soon, so it might not be worth the effort to invest into a fix in stac-layer right now. That means on the other hand that a fix may take a little longer.
- ol-stac seems to have issue rendering the bands correctly.
FYI this is the expected result (getting the raster served as COG and http loaded in qgis)
So, seems that the image in stac-browser has the correct 0 reference but 90 right had rotated and scaled respect that shown into https://github.com/radiantearth/stac-browser/issues/407#issuecomment-2577394049
- stac-layer seems to use a very outdated geotiff.js version and (through georaster-layer-for-leaflet, see https://github.com/GeoTIFF/georaster-layer-for-leaflet/issues) uses potentially a different projection methodology compared to ol-stac. So the issue might be sitting there, we had issues with it in the past.
just in case, testing with stac-layer@next instead of that packaged with 0.15.0
@luipir I think that's a dead end. stac-layer@next primarily improved on the STAC side of things, not of the COG rendering. The issues come likely from georaster, which has open issues... For the meantime you could enable tilserver rendering.
This is fixed in #531.