Element84 / earth-search

Earth Search information and issue tracking
https://earth-search.aws.element84.com/v1
27 stars 2 forks source link

sentinel-2-l2a invalid STAC shape and transform #48

Open jmettes opened 1 month ago

jmettes commented 1 month ago

For the overview, wvp and aot assets in STAC document for sentinel-2-l2a collection, the shape and transforms appear to be wrong (and raster:bands.spatial_resolution too).

So looking at an example AOT file with gdal, we see the actual values are indeed 60 meters pixels and size 1830x1830:

$ gdalinfo https://sentinel-cogs.s3.us-west-2.amazonaws.com\
/sentinel-s2-l2a-cogs/53/M/LM/2024/7/S2B_53MLM_20240709_0_L2A/AOT.tif
Driver: GTiff/GeoTIFF
Files: none associated
Size is 1830, 1830
Coordinate System is:
PROJCRS["WGS 84 / UTM zone 53S",
    BASEGEOGCRS["WGS 84",
        DATUM["World Geodetic System 1984",
            ELLIPSOID["WGS 84",6378137,298.257223563,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4326]],
    CONVERSION["UTM zone 53S",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",135,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9996,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",500000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",10000000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["(E)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["(N)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Navigation and medium accuracy spatial referencing."],
        AREA["Between 132°E and 138°E, southern hemisphere between 80°S and equator, onshore and offshore. Australia. Indonesia."],
        BBOX[-80,132,0,138]],
    ID["EPSG",32753]]
Data axis to CRS axis mapping: 1,2
Origin = (300000.000000000000000,9200020.000000000000000)
Pixel Size = (60.000000000000000,-60.000000000000000)
Metadata:
  OVR_RESAMPLING_ALG=MODE
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=DEFLATE
  INTERLEAVE=BAND
  PREDICTOR=2
Corner Coordinates:
Upper Left  (  300000.000, 9200020.000) (133d11'19.03"E,  7d14' 1.26"S)
Lower Left  (  300000.000, 9090220.000) (133d11' 3.78"E,  8d13'35.03"S)
Upper Right (  409800.000, 9200020.000) (134d10'58.65"E,  7d14'11.59"S)
Lower Right (  409800.000, 9090220.000) (134d10'51.76"E,  8d13'46.79"S)
Center      (  354900.000, 9145120.000) (133d41' 3.30"E,  7d43'54.73"S)
Band 1 Block=256x256 Type=UInt16, ColorInterp=Gray
  NoData Value=0
  Overviews: 915x915, 458x458, 229x229

But then comparing that to the STAC file and STAC API response, it's reported as pixel size of 20m and 5490x5490 size.

$ curl --silent 'https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a\
/items/S2B_53MLM_20240709_0_L2A' | jq -r '.assets["aot"]'
{
  "href": "https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/53/M/LM/2024/7/S2B_53MLM_20240709_0_L2A/AOT.tif",
  "type": "image/tiff; application=geotiff; profile=cloud-optimized",
  "title": "Aerosol optical thickness (AOT)",
  "proj:shape": [
    5490,
    5490
  ],
  "proj:transform": [
    20,
    0,
    300000,
    0,
    -20,
    9200020
  ],
  "raster:bands": [
    {
      "nodata": 0,
      "data_type": "uint16",
      "bits_per_sample": 15,
      "spatial_resolution": 20,
      "scale": 0.001,
      "offset": 0
    }
  ],
  "roles": [
    "data",
    "reflectance"
  ]
}
$ aws s3 cp --no-sign-request --region us-west-2 s3://sentinel-cogs\
/sentinel-s2-l2a-cogs/53/M/LM/2024/7/S2B_53MLM_20240709_0_L2A/S2B_53MLM_20240709_0_L2A.json - | jq -r '.assets["aot"]'
{
  "href": "https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/53/M/LM/2024/7/S2B_53MLM_20240709_0_L2A/AOT.tif",
  "type": "image/tiff; application=geotiff; profile=cloud-optimized",
  "title": "Aerosol optical thickness (AOT)",
  "proj:shape": [
    5490,
    5490
  ],
  "proj:transform": [
    20.0,
    0.0,
    300000.0,
    0.0,
    -20.0,
    9200020.0
  ],
  "raster:bands": [
    {
      "nodata": 0,
      "data_type": "uint16",
      "bits_per_sample": 15,
      "spatial_resolution": 20,
      "scale": 0.001,
      "offset": 0
    }
  ],
  "roles": [
    "data",
    "reflectance"
  ]
}

It also appears the SNS topic messages from cirrus-v0-publish for this collection have the correct values too. So somehow whatever produces the STAC info is out of sync with the files themselves and whatever produces the SNS messages (see sample message)

$ cat s2_l2a_example_message.json | jq -r '.Message | fromjson| .assets["AOT"]'
{
  "title": "Aerosol Optical Thickness (AOT)",
  "type": "image/tiff; application=geotiff; profile=cloud-optimized",
  "roles": [
    "data"
  ],
  "href": "https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/20/X/NP/2024/5/S2A_20XNP_20240513_1_L2A/AOT.tif",
  "proj:shape": [
    1830,
    1830
  ],
  "proj:transform": [
    60.0,
    0.0,
    499980.0,
    0.0,
    -60.0,
    8900040.0,
    0.0,
    0.0,
    1.0
  ]
}