From 81431c23261b001f89802036116219b9f3401e45 Mon Sep 17 00:00:00 2001 From: Elien Vandermaesen Date: Thu, 19 Dec 2024 08:28:18 +0100 Subject: [PATCH] issue #678 support shapely and local path in load collection, make changes clear --- openeo/rest/connection.py | 5 ++++- openeo/rest/datacube.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/openeo/rest/connection.py b/openeo/rest/connection.py index 77d4fc759..44a100746 100644 --- a/openeo/rest/connection.py +++ b/openeo/rest/connection.py @@ -1244,12 +1244,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. @@ -1268,6 +1268,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, diff --git a/openeo/rest/datacube.py b/openeo/rest/datacube.py index 7f12dcfb7..457b7e61c 100644 --- a/openeo/rest/datacube.py +++ b/openeo/rest/datacube.py @@ -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. @@ -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) @@ -193,7 +196,9 @@ def load_collection( "Unexpected parameterized `spatial_extent` in `load_collection`:" f" expected schema 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 = [ @@ -2871,4 +2876,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 \ No newline at end of file + return geometry