stac-extensions/ml-aoi

Invalid STAC Item/Asset schema definition (?)

fmigneault opened this issue · 2 comments

@duckontheweb @m-mohr

I would like to know if I am misinterpreting this extension's specification, and whether I am placing the fields in the wrong location or not, or that the schema has an actual error?

I have a STAC Item definition (which uses many other STAC extensions), that tries to apply ml-aoi as well.
Whenever I apply the following changes, schema validation of ml-aoi fails.

  "assets": {
    "labels": {
      "title": "Labels for image AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/label/AnnualCrop/AnnualCrop_1636.geojson",
-      "type": "application/geo+json"
+      "type": "application/geo+json",
+      "ml-aoi:role": "label"
    },
    "raster": {
      "title": "Raster AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/AnnualCrop/AnnualCrop_1636.tif",
      "type": "image/tiff; application=geotiff",
      "raster:bands": [
        }
-      ]
+      ],
+      "ml-aoi:role": "feature",
+      "ml-aoi:reference-grid": true
    },

I am refering to https://github.com/stac-extensions/ml-aoi#assets regarding the addition of these fields.
It seems to suggest that they are intended to be defined under the assets objects, but doing so fails because of the combination of

"assets": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/fields"
}

"patternProperties": {
"^(?!ml-aoi:)": {}
},
"additionalProperties": false

The only ml-aoi field that is accepted is the "ml-aoi:split": "test" defined within the STAC Item's properties.

Below is the full contents of the STAC Item with/without ml-aoi for comparison.
Every other STAC extension schema succeeds validation.

STAC Item With ML-AOI

{
  "stac_version": "1.0.0",
  "stac_extensions": [
    "https://stac-extensions.github.io/eo/v1.1.0/schema.json",
    "https://stac-extensions.github.io/file/v1.0.0/schema.json",
    "https://stac-extensions.github.io/raster/v1.1.0/schema.json",
    "https://stac-extensions.github.io/label/v1.0.1/schema.json",
    "https://stac-extensions.github.io/ml-aoi/v0.1.0/schema.json",
    "https://stac-extensions.github.io/version/v1.0.0/schema.json"
  ],
  "type": "Feature",
  "id": "EuroSAT-subset-test-sample-0-class-AnnualCrop",
  "title": "EuroSAT subset test sample 0 class AnnualCrop",
  "description": "Annotated sample from the EuroSAT-subset-test collection.",
  "bbox": [
    22.854989915168744,
    49.836213455735006,
    22.864099797549315,
    49.84210863494964
  ],
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          16.511460954898432,
          0.00044949166508093715
        ],
        [
          16.5114609548984,
          0.00044954483593276134
        ],
        [
          16.51146087328297,
          0.000449544835882152
        ],
        [
          16.511460873283003,
          0.0004494916650303338
        ],
        [
          16.511460954898432,
          0.00044949166508093715
        ]
      ]
    ]
  },
  "assets": {
    "labels": {
      "title": "Labels for image AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/label/AnnualCrop/AnnualCrop_1636.geojson",
      "type": "application/geo+json",
      "ml-aoi:role": "label"
    },
    "raster": {
      "title": "Raster AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/AnnualCrop/AnnualCrop_1636.tif",
      "type": "image/tiff; application=geotiff",
      "raster:bands": [
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        }
      ],
      "ml-aoi:role": "feature",
      "ml-aoi:reference-grid": true
    },
    "thumbnail": {
      "title": "Preview of AnnualCrop_1636.",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/png/AnnualCrop/AnnualCrop_1636.png",
      "type": "image/png",
      "eo:bands": [
        {
          "name": "B04",
          "common_name": "red",
          "center_wavelength": 0.6645,
          "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.4966,
          "full_width_half_max": 0.098
        }
      ]
    }
  },
  "collection": "EuroSAT-subset-test",
  "properties": {
    "datetime": "2023-05-30T03:13:45.741375+00:00",
    "license": "MIT",
    "version": "1",
    "label:properties": [
      "class"
    ],
    "label:tasks": [
      "segmentation",
      "classification"
    ],
    "label:type": "vector",
    "label:methods": [
      "manual"
    ],
    "label:description": "Land-cover area classification on Sentinel-2 image.",
    "label:classes": [
      {
        "name": "class",
        "classes": [
          "AnnualCrop",
          "0"
        ]
      }
    ],
    "label:overviews": [
      {
        "property_key": "class",
        "counts": [
          {
            "name": "AnnualCrop",
            "count": 1
          }
        ]
      }
    ],
    "ml-aoi:split": "test",
    "constellation": "sentinel-2",
    "instruments": [
      "msi"
    ],
    "eo:bands": [
      {
        "name": "B01",
        "common_name": "coastal",
        "center_wavelength": 0.4439,
        "full_width_half_max": 0.027
      },
      {
        "name": "B02",
        "common_name": "blue",
        "center_wavelength": 0.4966,
        "full_width_half_max": 0.098
      },
      {
        "name": "B03",
        "common_name": "green",
        "center_wavelength": 0.56,
        "full_width_half_max": 0.045
      },
      {
        "name": "B04",
        "common_name": "red",
        "center_wavelength": 0.6645,
        "full_width_half_max": 0.038
      },
      {
        "name": "B05",
        "center_wavelength": 0.7039,
        "full_width_half_max": 0.019,
        "common_name": "rededge"
      },
      {
        "name": "B06",
        "center_wavelength": 0.7402,
        "full_width_half_max": 0.018,
        "common_name": "rededge"
      },
      {
        "name": "B07",
        "center_wavelength": 0.7825,
        "full_width_half_max": 0.028,
        "common_name": "rededge"
      },
      {
        "name": "B08",
        "common_name": "nir",
        "center_wavelength": 0.8351,
        "full_width_half_max": 0.145
      },
      {
        "name": "B08A",
        "center_wavelength": 0.8648,
        "full_width_half_max": 0.033,
        "common_name": "nir08"
      },
      {
        "name": "B09",
        "center_wavelength": 0.945,
        "full_width_half_max": 0.026,
        "common_name": "nir09"
      },
      {
        "name": "B10",
        "common_name": "cirrus",
        "center_wavelength": 1.3735,
        "full_width_half_max": 0.075
      },
      {
        "name": "B11",
        "common_name": "swir16",
        "center_wavelength": 1.6137,
        "full_width_half_max": 0.143
      },
      {
        "name": "B12",
        "common_name": "swir22",
        "center_wavelength": 2.22024,
        "full_width_half_max": 0.242
      }
    ],
    "view:off_nadir": 0,
    "gsd": 10
  },
  "links": [
    {
      "title": "Preview of AnnualCrop_1636.",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/png/AnnualCrop/AnnualCrop_1636.png",
      "type": "image/png",
      "rel": "thumbnail"
    },
    {
      "title": "Raster AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/AnnualCrop/AnnualCrop_1636.tif",
      "type": "image/tiff; application=geotiff",
      "rel": "source",
      "label:assets": [
        "labels",
        "raster"
      ]
    },
    {
      "title": "Raster AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/AnnualCrop/AnnualCrop_1636.tif",
      "type": "image/tiff; application=geotiff",
      "rel": "derived_from",
      "ml-aoi:role": "feature"
    },
    {
      "rel": "root",
      "href": "https://example.com/catalog.json",
      "type": "application/json"
    },
    {
      "rel": "parent",
      "href": "https://example.com/EuroSAT/stac/subset/test/collection.json",
      "type": "application/json",
      "title": "EuroSAT STAC Collection with samples from 'test' split."
    },
    {
      "rel": "collection",
      "href": "https://example.com/EuroSAT/stac/subset/test/collection.json",
      "type": "application/json",
      "title": "EuroSAT STAC Collection with samples from 'test' split."
    },
    {
      "rel": "self",
      "href": "https://example.com/EuroSAT/stac/subset/test/item-0.json",
      "type": "application/geo+json"
    }
  ]
}

STAC Item Without ML-AOI

{
  "stac_version": "1.0.0",
  "stac_extensions": [
    "https://stac-extensions.github.io/eo/v1.1.0/schema.json",
    "https://stac-extensions.github.io/file/v1.0.0/schema.json",
    "https://stac-extensions.github.io/raster/v1.1.0/schema.json",
    "https://stac-extensions.github.io/label/v1.0.1/schema.json",
    "https://stac-extensions.github.io/ml-aoi/v0.1.0/schema.json",
    "https://stac-extensions.github.io/version/v1.0.0/schema.json"
  ],
  "type": "Feature",
  "id": "EuroSAT-subset-test-sample-0-class-AnnualCrop",
  "title": "EuroSAT subset test sample 0 class AnnualCrop",
  "description": "Annotated sample from the EuroSAT-subset-test collection.",
  "bbox": [
    22.854989915168744,
    49.836213455735006,
    22.864099797549315,
    49.84210863494964
  ],
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          16.511460954898432,
          0.00044949166508093715
        ],
        [
          16.5114609548984,
          0.00044954483593276134
        ],
        [
          16.51146087328297,
          0.000449544835882152
        ],
        [
          16.511460873283003,
          0.0004494916650303338
        ],
        [
          16.511460954898432,
          0.00044949166508093715
        ]
      ]
    ]
  },
  "assets": {
    "labels": {
      "title": "Labels for image AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/label/AnnualCrop/AnnualCrop_1636.geojson",
      "type": "application/geo+json"
														
    },
    "raster": {
      "title": "Raster AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/AnnualCrop/AnnualCrop_1636.tif",
      "type": "image/tiff; application=geotiff",
      "raster:bands": [
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        },
        {
          "nodata": 0,
          "unit": "m",
          "spatial_resolution": 10
        }
      ]
															 
																	 
    },
    "thumbnail": {
      "title": "Preview of AnnualCrop_1636.",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/png/AnnualCrop/AnnualCrop_1636.png",
      "type": "image/png",
      "eo:bands": [
        {
          "name": "B04",
          "common_name": "red",
          "center_wavelength": 0.6645,
          "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.4966,
          "full_width_half_max": 0.098
        }
      ]
    }
  },
  "collection": "EuroSAT-subset-test",
  "properties": {
    "datetime": "2023-05-30T03:22:14.611699+00:00",
    "license": "MIT",
    "version": "1",
    "label:properties": [
      "class"
    ],
    "label:tasks": [
      "segmentation",
      "classification"
    ],
    "label:type": "vector",
    "label:methods": [
      "manual"
    ],
    "label:description": "Land-cover area classification on Sentinel-2 image.",
    "label:classes": [
      {
        "name": "class",
        "classes": [
          "AnnualCrop",
          "0"
        ]
      }
    ],
    "label:overviews": [
      {
        "property_key": "class",
        "counts": [
          {
            "name": "AnnualCrop",
            "count": 1
          }
        ]
      }
    ],
    "ml-aoi:split": "test",
    "constellation": "sentinel-2",
    "instruments": [
      "msi"
    ],
    "eo:bands": [
      {
        "name": "B01",
        "common_name": "coastal",
        "center_wavelength": 0.4439,
        "full_width_half_max": 0.027
      },
      {
        "name": "B02",
        "common_name": "blue",
        "center_wavelength": 0.4966,
        "full_width_half_max": 0.098
      },
      {
        "name": "B03",
        "common_name": "green",
        "center_wavelength": 0.56,
        "full_width_half_max": 0.045
      },
      {
        "name": "B04",
        "common_name": "red",
        "center_wavelength": 0.6645,
        "full_width_half_max": 0.038
      },
      {
        "name": "B05",
        "center_wavelength": 0.7039,
        "full_width_half_max": 0.019,
        "common_name": "rededge"
      },
      {
        "name": "B06",
        "center_wavelength": 0.7402,
        "full_width_half_max": 0.018,
        "common_name": "rededge"
      },
      {
        "name": "B07",
        "center_wavelength": 0.7825,
        "full_width_half_max": 0.028,
        "common_name": "rededge"
      },
      {
        "name": "B08",
        "common_name": "nir",
        "center_wavelength": 0.8351,
        "full_width_half_max": 0.145
      },
      {
        "name": "B08A",
        "center_wavelength": 0.8648,
        "full_width_half_max": 0.033,
        "common_name": "nir08"
      },
      {
        "name": "B09",
        "center_wavelength": 0.945,
        "full_width_half_max": 0.026,
        "common_name": "nir09"
      },
      {
        "name": "B10",
        "common_name": "cirrus",
        "center_wavelength": 1.3735,
        "full_width_half_max": 0.075
      },
      {
        "name": "B11",
        "common_name": "swir16",
        "center_wavelength": 1.6137,
        "full_width_half_max": 0.143
      },
      {
        "name": "B12",
        "common_name": "swir22",
        "center_wavelength": 2.22024,
        "full_width_half_max": 0.242
      }
    ],
    "view:off_nadir": 0,
    "gsd": 10
  },
  "links": [
    {
      "title": "Preview of AnnualCrop_1636.",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/png/AnnualCrop/AnnualCrop_1636.png",
      "type": "image/png",
      "rel": "thumbnail"
    },
    {
      "title": "Raster AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/AnnualCrop/AnnualCrop_1636.tif",
      "type": "image/tiff; application=geotiff",
      "rel": "source",
      "label:assets": [
        "labels",
        "raster"
      ]
    },
    {
      "title": "Raster AnnualCrop_1636 with AnnualCrop class",
      "href": "https://example.com/EuroSAT/data/subset/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/AnnualCrop/AnnualCrop_1636.tif",
      "type": "image/tiff; application=geotiff",
      "rel": "derived_from",
      "ml-aoi:role": "feature"
    },
    {
      "rel": "root",
      "href": "https://example.com/catalog.json",
      "type": "application/json"
    },
    {
      "rel": "parent",
      "href": "https://example.com/EuroSAT/stac/subset/test/collection.json",
      "type": "application/json",
      "title": "EuroSAT STAC Collection with samples from 'test' split."
    },
    {
      "rel": "collection",
      "href": "https://example.com/EuroSAT/stac/subset/test/collection.json",
      "type": "application/json",
      "title": "EuroSAT STAC Collection with samples from 'test' split."
    },
    {
      "rel": "self",
      "href": "https://example.com/EuroSAT/stac/subset/test/item-0.json",
      "type": "application/geo+json"
    }
  ]
}

I've not written or worked with this extension yet, sorry. Please ask the owners.

@echeipesh @kbgg @duckontheweb Any input from the spec owners would be greatly appreciated.