Skip to content

Instantly share code, notes, and snippets.

@alexgleith
Last active April 10, 2024 18:38
Show Gist options
  • Star 96 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexgleith/dc49156aab4b9270b0a0f145bd7fa0ce to your computer and use it in GitHub Desktop.
Save alexgleith/dc49156aab4b9270b0a0f145bd7fa0ce to your computer and use it in GitHub Desktop.
Simplest example for finding and loading Sentinel-2 data using Python
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TiensiDua
Copy link

oke

@krishnaglodha
Copy link

Hi, can you please tell me how can I loop through multiple tiles and download the raw data in my local machine ?

@alexgleith
Copy link
Author

Hey @krishnaglodha

At the top, add import odc.geo and then you can use the odc extension for xarrays, so you can do:

data.red.isel(time=0).odc.write_cog("out.tif")

@zxdawn
Copy link

zxdawn commented Feb 3, 2024

Nice notebook. You can filter cloud cover like this:

search = client.search(collections = [collection],
                       bbox = tas_bbox,
                       datetime = '2023-01-01/2023-12-31',
                       query = {"eo:cloud_cover":{"lt":0.2}},
                       max_items=10,
                       )

@alexgleith
Copy link
Author

You can filter cloud cover like this:

Hey @zxdawn, you can filter out scenes like that, but often you want to keep all the valid pixels you can, in which case, doing a per-pixel cloud mask is better.

That's not covered in this simple example, but I did include it in this different example .

@zxdawn
Copy link

zxdawn commented Feb 6, 2024

@alexgleith Thanks for the tip! Actually, I'm still confused about the eo:cloud_cover option. Is that the cloud fraction over the bbox or the whole scene?

@alexgleith
Copy link
Author

Is that the cloud fraction over the bbox or the whole scene?

It's for each of the individual scenes (STAC Items).

@shahriarEbram
Copy link

Thank you for notebook.
Can you tell me what is tas_bbox and how can I use latitude and longitude instead?

@alexgleith
Copy link
Author

Hi @shahriarEbram I've expanded the comments to describe what each step is doing. Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment