Skip to content

Commit

Permalink
issue #678 support shapely and local path in load collection, make ch…
Browse files Browse the repository at this point in the history
…anges clear
  • Loading branch information
ElienVandermaesenVITO authored and soxofaan committed Jan 17, 2025
1 parent 7acf9c7 commit 3745f4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion openeo/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,12 +1270,12 @@ def load_collection(
:param collection_id: image collection identifier
:param spatial_extent: limit data to specified bounding box or polygons. Can be provided in different ways:
- a bounding box dictionary
- a shapely geometry
- a GeoJSON-style dictionary,
- a path (:py:class:`str` or :py:class:`~pathlib.Path`) to a local, client-side GeoJSON file,
which will be loaded automatically to get the geometries as GeoJSON construct.
- a :py:class:`~openeo.api.process.Parameter` instance.
- a bounding box dictionary
:param temporal_extent: limit data to specified temporal interval.
Typically, just a two-item list or tuple containing start and end date.
See :ref:`filtering-on-temporal-extent-section` for more details on temporal extent handling and shorthand notation.
Expand All @@ -1294,6 +1294,9 @@ def load_collection(
.. versionchanged:: 0.26.0
Add :py:func:`~openeo.rest.graph_building.collection_property` support to ``properties`` argument.
.. versionchanged:: 0.37.0
Add support for shapely geometry and local path to GeoJSON file to spatial_extent argument.
"""
return DataCube.load_collection(
collection_id=collection_id,
Expand Down
11 changes: 8 additions & 3 deletions openeo/rest/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ def load_collection(
:param connection: The backend connection to use.
Can be ``None`` to work without connection and collection metadata.
:param spatial_extent: limit data to specified bounding box or polygons. Can be provided in different ways:
- a bounding box dictionary
- a shapely geometry
- a GeoJSON-style dictionary,
- a path (:py:class:`str` or :py:class:`~pathlib.Path`) to a local, client-side GeoJSON file,
which will be loaded automatically to get the geometries as GeoJSON construct.
- a :py:class:`~openeo.api.process.Parameter` instance.
- a bounding box dictionary
:param temporal_extent: limit data to specified temporal interval.
Typically, just a two-item list or tuple containing start and end date.
See :ref:`filtering-on-temporal-extent-section` for more details on temporal extent handling and shorthand notation.
Expand All @@ -183,6 +183,9 @@ def load_collection(
.. versionchanged:: 0.26.0
Add :py:func:`~openeo.rest.graph_building.collection_property` support to ``properties`` argument.
.. versionchanged:: 0.37.0
Add support for shapely geometry and local path to GeoJSON file to spatial_extent argument.
"""
if temporal_extent:
temporal_extent = cls._get_temporal_extent(extent=temporal_extent)
Expand All @@ -193,7 +196,9 @@ def load_collection(
"Unexpected parameterized `spatial_extent` in `load_collection`:"
f" expected schema compatible with type 'object' but got {spatial_extent.schema!r}."
)
elif not spatial_extent or (isinstance(spatial_extent, dict) and spatial_extent.keys() & {"west", "east", "north", "south"}):
elif spatial_extent is None or (
isinstance(spatial_extent, dict) and spatial_extent.keys() & {"west", "east", "north", "south"}
):
pass
else:
valid_geojson_types = [
Expand Down Expand Up @@ -2936,4 +2941,4 @@ def _get_geometry_argument(
warnings.warn(f"non-Lon-Lat CRS {crs!r} is not known to the proj library and might not be supported.")
crs_name = crs
geometry["crs"] = {"type": "name", "properties": {"name": crs_name}}
return geometry
return geometry

0 comments on commit 3745f4d

Please sign in to comment.