Skip to content

Unable to control subfolders with LayoutTemplate #480

@scottyhq

Description

@scottyhq

the generate_subcatalogs() command is very handy for creating new catalogs with a layout based on STAC item properties! But it seems there is a bug or missing documentation. All the examples seem to map 1 property to 1 subfolder (https://pystac.readthedocs.io/en/latest/api.html?highlight=template#templating).

In many cases it can be useful to merge properties names into a single subfolder name or do some other customization. For example I was expecting the template string to behave like a python f'string'. In fact it looks like the '/' and all other characters outside ${} are ignored

template = '${mgrs:utm_zone}${mgrs:latitude_band}${mgrs:grid_square}/${year}'
collection.generate_subcatalogs(template=template)
collection.describe()

Expected Output:

* <Collection id=sentinel1-rtc-aws>
    * <Catalog id=10UCU>
        * <Catalog id=2017>
          * <Item id=S1A_20170101_10UCU_ASC>
          * <Item id=S1A_20170125_10UCU_ASC>
          * <Item id=S1B_20170102_10UCU_ASC>

Actual Output:

* <Collection id=sentinel1-rtc-aws>
    * <Catalog id=10>
        * <Catalog id=U>
            * <Catalog id=CU>
                * <Catalog id=2017>
                  * <Item id=S1A_20170101_10UCU_ASC>
                  * <Item id=S1A_20170125_10UCU_ASC>
                  * <Item id=S1B_20170102_10UCU_ASC>

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