Using S3
In this example, we’ll configure pygeodes to use AWS S3, search for items from Geodes and download these items using S3.
Imports¶
from pygeodes import Geodes, ConfigConfiguration¶
Let’s configure geodes, as we will want to use S3 downloading, we need to provide our AWS S3 credentials, under the following format :
{"aws_access_key_id" : "my_access_key_id","aws_secret_access_key" : "my_secret_access_key_id","aws_session_token" : "my_session_token","download_dir" : "/tmp/downloads"}(we also provide a download dir in /tmp to avoid overloading our current working directory)
conf = Config.from_file("config.json")
geodes = Geodes(conf)Searching products¶
Now, let’s search for products to download, by geometry, cloud cover and date (we use complete_datetime_from_str to convert to geodes’s datetime format) :
from pygeodes.utils.datetime_utils import complete_datetime_from_str
geometry = {
"coordinates": [
[
[122.04593762282985, 30.667759206439726],
[121.95364958668256, 30.612924786294755],
[121.99524128010273, 30.54808041765598],
[122.11049786336304, 30.5473676013261],
[122.16760884537177, 30.599211325380764],
[122.14526106980247, 30.64746697336838],
[122.04593762282985, 30.667759206439726],
]
],
"type": "Polygon",
}
date = complete_datetime_from_str("2024-07-01")
items, dataframe = geodes.search_items(
intersects=geometry,
query={
"eo:cloud_cover": {"lte": 5},
"end_datetime": {"gte": date},
},
)/work/scratch/data/fournih/test_env/lib/python3.11/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'geodes-portal.cnes.fr'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
warnings.warn(
Found 136 items matching your query, returning 80 as get_all parameter is set to False
80 item(s) found for query : {'eo:cloud_cover': {'lte': 5}, 'end_datetime': {'gte': '2024-07-01T00:00:00.000000Z'}}
To learn more about how to search items, see the docs. Let’s explore our results on a map :
dataframe.explore()To learn more about manipulating dataframes, see the docs.
Downloading our items using S3¶
As we provided an S3 conf, pygeodes will automatically use an S3 client instead of geodes to download your products (for further details, see the docs) :
geodes.download_item_archives(items)