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

Filtering down spectral bands #409

Closed
jparal opened this issue Dec 8, 2023 · 3 comments
Closed

Filtering down spectral bands #409

jparal opened this issue Dec 8, 2023 · 3 comments

Comments

@jparal
Copy link

jparal commented Dec 8, 2023

Hi, I am trying to download Harmonized Landsat Sentinel (HLS) dataset from earthdata using earthaccess. A single granule contains several spectral bands and mask(s) but for our use case, I only need a subset.
Is there a way for me to select a subset of the bands either using search_data API call or manually after getting the result of the search and before passing it onto download()?

Thx, J

@MattF-NSIDC
Copy link

What collection are you looking at?

I did a search and looks like there's a collection containing band-specific cloud-optimized geotiffs for this dataset (collection 10.5067/HLS/HLSS30.002) : https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSS30.020/HLS.S30.T01KBU.2023340T220911.v2.0/HLS.S30.T01KBU.2023340T220911.v2.0.B10.tif.

For this collection you could use the granule_name argument to search_data to select the bands you want before downloading.

@betolink
Copy link
Member

betolink commented Dec 10, 2023

Hi @jparal, if you know the name of the bands you want to filter you can definitely do it, here is an example after we get our results from search_data()

filtered_urls = []

for granule in results:
    links = granule.data_links()
    for link in links:
        if any(pattern in link for pattern in ["B02", "B01"]):
            filtered_urls.append(link)
            
earthaccess.download(filtered_urls, "HLS_DATA")

This notebook from LP DAAC does something similar, https://nasa-openscapes.github.io/earthdata-cloud-cookbook/tutorials/Observing_Seasonal_Ag_Changes.html#finding-hls-data-using-earthaccess Let us know if this helps!

@jparal
Copy link
Author

jparal commented Dec 11, 2023

Thank you, this is helpful. I could do it manually as you suggested and wrap the results in some regex filter. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants