Skip to content

Proper handling of root relative hrefs #1597

@soxofaan

Description

@soxofaan

We're struggling with a use case where items have "root relative" hrefs to assets and pystac does not provide a valid absolute href:

>>> import pystac
>>> pystac.__version__
'1.14.1'
>>> item = pystac.read_file("https://eoresults.esa.int/stac/collections/FCM-AGB-100m/items/FCM-AGB-100m-2017")
>>> asset = item.assets["PRODUCT"]
>>> asset.href
'/d/FCM-AGB-100m/2017/01/01/FCM-AGB-100m-2017/FCM_Europe_demo_2017_AGB.tif'
>>> asset.get_absolute_href()
'/d/FCM-AGB-100m/2017/01/01/FCM-AGB-100m-2017/FCM_Europe_demo_2017_AGB.tif'

The expectation is to get absolute href https://eoresults.esa.int/d/FCM-AGB-100m/2017/01/01/FCM-AGB-100m-2017/FCM_Europe_demo_2017_AGB.tif

Relevant parts of item STAC:

{
  "id": "FCM-AGB-100m-2017",
  "type": "Feature",
  "links": [
    {
      "rel": "root",
      "type": "application/json",
      "href": "https://eoresults.esa.int/stac/"
    },
    {
      "rel": "self",
      "type": "application/geo+json",
      "href": "https://eoresults.esa.int/stac/collections/FCM-AGB-100m/items/FCM-AGB-100m-2017"
    }
  ],
  "assets": {
    "PRODUCT": {
      "href": "/d/FCM-AGB-100m/2017/01/01/FCM-AGB-100m-2017/FCM_Europe_demo_2017_AGB.tif",
      "type": "image/tiff; application=geotiff",
      "roles": ["data"],
      "title": "Product",
    }
  },

note: STAC browser does produce the expected asset href: https://radiantearth.github.io/stac-browser/#/external/eoresults.esa.int/stac/collections/FCM-AGB-100m/items/FCM-AGB-100m-2017

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions