developmentseed / titiler-cmr

Dynamic tiles from CMR queries
MIT License
5 stars 0 forks source link

handle multiple `links` (assets) in results #18

Closed vincentsarago closed 7 months ago

vincentsarago commented 7 months ago

Let's take HLS data as example (concept_id="C2021957657-LPCLOUD")!

For a cmr search query we will have a list of list as results in form of

[
    // granule 1
    [
        "....path_b1.tif",
        "....path_b2.tif",
        "....path_b3.tif",
        "....path_b4.tif", 
        "..."
    ],

    // granule 1
    [
        "....path_b1.tif",
        "....path_b2.tif",
        "....path_b3.tif",
        "....path_b4.tif", 
        "..."
    ]
]
import earthaccess
import morecantile

tms = morecantile.tms.get("WebMercatorQuad")

bounds = tms.bounds(116, 78, 7)
xmin, ymin, xmax, ymax = (round(n, 8) for n in bounds)

results = earthaccess.search_data(
    bounding_box=(xmin, ymin, xmax, ymax),
    count=1,
    concept_id="C2021957657-LPCLOUD",
    temporal=("2024-02-11", "2024-02-12"),
)

print(results[0].data_links(access="direct"))

>> ['s3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B01.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B10.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B02.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B06.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B03.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.SZA.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B11.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.VAA.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B09.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B05.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.Fmask.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.SAA.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.VZA.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B04.tif',
 's3://lp-prod-protected/HLSL30.020/HLS.L30.T55HEV.2024042T000309.v2.0/HLS.L30.T55HEV.2024042T000309.v2.0.B07.tif']

https://github.com/developmentseed/titiler-cmr/blob/68b056894e92c556313c5693c7b3291fe000505a/titiler/cmr/backend.py#L173-L184

as mentioned in https://github.com/developmentseed/stac-explorer/issues/24 we need a way to discriminate each link in order to be able to create multi band visualization (RGB).

We will also need to use a different Reader to handle multiple files (rio_tiler.io.MultiBaseReader).