Skip to main content

I am using pystac to query the Catalog API and have come across a problem. I can retrieve the Catalog . I then attempt to walk over the children of above. When I do this, I get a response from the API, but the parsing of this by pystac fails due to a problem with the interval value, which is as shown below:


“temporal”:{“interval”:r“2015-11-01T00:00:00Z”,null]}


Looking at the STAC API reference, it appears that the interval value should always be an array of arrays, even if the top array only contains a single sub-array: stac-spec/collection-spec.md at master · radiantearth/stac-spec · GitHub


The example given at the above page (notice the outer array):


r "2019-01-01T00:00:00Z", null]]


Thus is appears to me that the result being returned from sentinel hub is not STAC compliant due to the time interval not being wrapped in an outer array.


I can patch pystac for now for my own purposes, but would be good to get clarification on whether the result returned from the API is as expected, or not? Could this be an API version issue?

Here’s my patch to collection.py in pystac to handle this:


@staticmethod

def from_dict(d):

“”"Constructs an TemporalExtent from a dict.


    Returns:
TemporalExtent: The TemporalExtent deserialized from the JSON dict.
"""

# Fix for Sentinel Hub non-compliance of Collection temporal interval JSON value
patch = False
if(type(dt'interval']r0])) == str:
patch = True

parsed_intervals = a]
if(patch == False):
# Original code
for i in di'interval']:
start = None
end = None
if i 0]:
start = dateutil.parser.parse(ia0])
if i 1]:
end = dateutil.parser.parse(ia1])
parsed_intervals.append(pstart, end])
else:
# Fix for non-compliant result from Sentinel Hub
start = None
end = None
if d 'interval']r0]:
start = dateutil.parser.parse(da'interval']r0])
if d 'interval']r1]:
end = dateutil.parser.parse(da'interval']r1])
parsed_intervals.append(pstart, end])

return TemporalExtent(intervals=parsed_intervals)

Reply