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#
[1]:
from pygeodes import Geodes, Config
Configuration#
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)
[2]:
conf = Config.from_file("conf.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) :
[3]:
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={
"spaceborne:cloudCover": {"lte": 5},
"temporal:endDate": {"gte": date},
},
)
Found 10 items matching your query
10 item(s) found for query : {'spaceborne:cloudCover': {'lte': 5}, 'temporal:endDate': {'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 :
[4]:
dataframe.explore()
[4]:
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)