Skip to content

Random asset ordering with stacrs.readΒ #85

@scottyhq

Description

@scottyhq

I noticed recently working with stacrs (0.5.9) to update an existing catalog results in large diffs because the asset ordering keeps changing:

import stacrs 
import pystac

href = 'https://raw.githubusercontent.com/stac-utils/pystac/refs/heads/main/tests/data-files/eo/eo-landsat-example.json'
item = await stacrs.read(href)
item

This results in a different order of assets each time. However properties and other entries do seem consistently ordered...

'assets': {'B11': {'href': 'https://landsat-pds.s3.amazonaws.com/c1/L8/107/018/LC08_L1TP_107018_20181001_20181001_01_RT/LC08_L1TP_107018_20181001_20181001_01_RT_B11.TIF',
   'title': 'Band 11 (lwir)',
   'type': 'image/tiff; application=geotiff',
   'eo:bands': [{'name': 'B11',
     'common_name': 'lwir12',
     'center_wavelength': 12,
     'full_width_half_max': 1}]},
  'B4': {'href': 'https://landsat-pds.s3.amazonaws.com/c1/L8/107/018/LC08_L1TP_107018_20181001_20181001_01_RT/LC08_L1TP_107018_20181001_20181001_01_RT_B4.TIF',
   'title': 'Band 4 (red)',
   'type': 'image/tiff; application=geotiff',
   'eo:bands': [{'name': 'B4',
     'common_name': 'red',
     'center_wavelength': 0.65,
     'full_width_half_max': 0.04}]},
...

Assets are consistently sorted with pystac:

item = pystac.read_file(href)
item.to_dict()
{'ANG': {'href': 'https://landsat-pds.s3.amazonaws.com/c1/L8/107/018/LC08_L1TP_107018_20181001_20181001_01_RT/LC08_L1TP_107018_20181001_20181001_01_RT_ANG.txt',
   'type': 'text/plain',
   'title': 'Angle coefficients file'},
  'B1': {'href': 'https://landsat-pds.s3.amazonaws.com/c1/L8/107/018/LC08_L1TP_107018_20181001_20181001_01_RT/LC08_L1TP_107018_20181001_20181001_01_RT_B1.TIF',
   'type': 'image/tiff; application=geotiff',
   'title': 'Band 1 (coastal)',
   'eo:bands': [{'name': 'B1',
     'common_name': 'coastal',
     'center_wavelength': 0.44,
     'full_width_half_max': 0.02,
     'solar_illumination': 2000}]},
...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions