radiantearth / stac-browser

A full-fledged UI in Vue for browsing and searching static STAC catalogs and STAC APIs
https://radiantearth.github.io/stac-browser
ISC License
287 stars 143 forks source link

Inversion of image outside of BBOX in STAC Browser #407

Open Ruphai opened 9 months ago

Ruphai commented 9 months ago

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?

image

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

t2m_20010103000000.zip

clausmichele commented 9 months ago

@m-mohr It might be related to this: https://github.com/geotiffjs/geotiff.js/pull/337

m-mohr commented 9 months ago

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?