-
Notifications
You must be signed in to change notification settings - Fork 4
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
First version of a rdm api interaction module #125 #161
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great! TBD how we can cope with authenticated calls to RDM which is one more addition that we probably need at this point.
…port devic flow authentication #125
@kvantricht , quite some changes since your last review: With the new changes made around authentication, a way to interact with the RDM API would now be as follows: from worldcereal.rdm_api import RdmInteraction
interaction = RdmInteraction().authenticate()
gdf = interaction.query_rdm(geometry=multi_polygon, temporal_extent=temporal_extent) Authentication now works similary to the OpenEO Python Client. You can also leave out For a STAC collection of patch extractions, you can extract the geometries of all patchtes into one import pystac
from shapely.geometry import shape, MultiPolygon
collection = pystac.read_file('/path/to/stac/collection.json')
polygons = []
for item in collection.get_items():
polygons.append(shape(item.geometry).buffer(1e-9)) # Add buffer to avoid TopologyException
multi_polygon = MultiPolygon(polygons)
temporal_extent = [collection.extent.temporal.intervals[0][0], collection.extent.temporal.intervals[0][1]] The results for a query on this MultiPolygon and temporal_extent look like this (cached 64x64 patches in pink, RDM query results in purple): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added two comments, other than that this looks good to merge so we can move on to the next step. Nice job!
|
||
for id in collection_ids: | ||
url = f"{self.RDM_ENDPOINT}/collections/{id}/download" | ||
response = requests.get(url, headers=self._get_headers()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need some resilience here? what's the timeout?
@kvantricht, added some resilience and a timeout to the RDM interaction. That should cover your final comments! |
Perfect, thanks! |
This is a first version of how we can construct a GeoParquet file from the RDM API, based on a user-defined AOI.
How it works:
A visualization of the output:
All feedback is welcome!