Skip to content

Instantly share code, notes, and snippets.

@alexgleith
Last active June 21, 2024 10:35
Show Gist options
  • 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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