Skip to content

How can I configure item output paths with additional subdirectories? #1564

@sgxl

Description

@sgxl

Hi maintainers,

I'm trying to customize the output directory structure when saving a STAC catalog using PySTAC. I have a pystac.Item object that I want to save under a specific path format likecatalog/collection_id/item_id/year-month/itemxx.json

I know that I can manually set the self HREF of the item via stac_item.set_self_href(...), and then add it to a collection and catalog like so:

stac_item.set_self_href(ofile_stac_item)

collection.add_item(stac_item)
collection.update_extent_from_items()

catalog.add_children([collection])
catalog.normalize_hrefs(stac_disk_path_base)    # stac_disk_path_base is the root path of the catalog
catalog.save(dest_href=stac_disk_path_base, catalog_type=pystac.CatalogType.SELF_CONTAINED)

While this correctly sets the self HREF for the item, the actual file is still being written to the default location:catalog/collection_id/item_id/xxx.json

It seems that even after calling set_self_href, the final output path used by save() doesn't respect the full custom path I provided (including the year-month subdirectory).

Is there currently a way to fully control the output directory structure during normalize_hrefs or save, especially to include additional path components such as year/month? If not, would this be a reasonable feature to request?

Thanks in advance for any guidance or suggestions.

Best regards,
Calf Lai

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions