Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow file separated band storage #19

Merged
merged 3 commits into from
Mar 5, 2024

Conversation

vincentsarago
Copy link
Member

closes #18

with CMRBackend() as backend:
    assets = backend.assets_for_tile(
        x=116,
        y=78,
        z=7,
        limit=1,
        concept_id="C2021957657-LPCLOUD",
        temporal=("2024-02-11", "2024-02-12")
    )
assets
>> [{'url': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B01.tif',
  'provider': 'LPCLOUD'}]
with CMRBackend() as backend:
    assets = backend.assets_for_tile(
        x=116,
        y=78,
        z=7,
        limit=1,
        bands_regex="B[0-9][0-9]",
        concept_id="C2021957657-LPCLOUD",
        temporal=("2024-02-11", "2024-02-12")
    )
assets
>> [{'url': {'B01': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B01.tif',
   'B10': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B10.tif',
   'B02': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B02.tif',
   'B06': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B06.tif',
   'B03': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B03.tif',
   'B11': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B11.tif',
   'B09': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B09.tif',
   'B05': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B05.tif',
   'B04': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B04.tif',
   'B07': 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B07.tif'},
  'provider': 'LPCLOUD'}]

In the endpoints this PR add two new options:

  • bands: e.g B01 key to use to specify the file url
  • bands_regex: e.g B[0-9][0-9], regex expression to use to find the band name in the URL

cc @sharkinsspatial

title="Band names",
description="Band names.",
),
] = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bands=B04&bands=B03&bands=B02

title="Regex expression to parse dataset links",
description="Regex expression to parse dataset links.",
),
] = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bands_regex="B[0-9][0-9]"

titiler/cmr/backend.py Outdated Show resolved Hide resolved
"provider": r["meta"]["provider-id"],
}
)
if bands_regex:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vincentsarago This looks good to me. In the future we may want consider a more explicit mapping of band id->band regex. Something like bands_regex=.*B10\.tif.*&bands_regex=.*B09\.tif.* so that we are only linking the same assets listed in the bands parameter but I think the approach you have here should be good until we find a dataset that breaks it :]

@vincentsarago vincentsarago marked this pull request as ready for review March 5, 2024 21:29
@vincentsarago vincentsarago merged commit e979693 into develop Mar 5, 2024
4 checks passed
@vincentsarago vincentsarago deleted the features/allow-file-separated-bands branch March 5, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

handle multiple links (assets) in results
2 participants