diff --git a/CHANGELOG.md b/CHANGELOG.md index 241f60fd3..1f4dd5dd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Automatically use `load_url` when providing a URL as geometries to `DataCube.aggregate_spatial()`, `DataCube.mask_polygon()`, etc. ([#104](https://github.com/Open-EO/openeo-python-client/issues/104), [#457](https://github.com/Open-EO/openeo-python-client/issues/457)) -- Argument `spatial_extent` in `load_collection` supports type `shapely` and loading geometry from a local path. +- Argument `spatial_extent` in `load_collection` supports Shapely objects and loading GeoJSON from a local path. ### Changed diff --git a/openeo/rest/connection.py b/openeo/rest/connection.py index a1befaa79..77d4fc759 100644 --- a/openeo/rest/connection.py +++ b/openeo/rest/connection.py @@ -1249,6 +1249,7 @@ def load_collection( - 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. diff --git a/openeo/rest/datacube.py b/openeo/rest/datacube.py index 4629c37d5..7f12dcfb7 100644 --- a/openeo/rest/datacube.py +++ b/openeo/rest/datacube.py @@ -164,6 +164,7 @@ def load_collection( - 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. @@ -192,11 +193,14 @@ def load_collection( "Unexpected parameterized `spatial_extent` in `load_collection`:" f" expected schema with type 'object' but got {spatial_extent.schema!r}." ) - valid_geojson_types = [ - "Polygon", "MultiPolygon", "Feature", "FeatureCollection" - ] - if spatial_extent and not (isinstance(spatial_extent, dict) and spatial_extent.keys() & {"west", "east", "north", "south"}): - spatial_extent = _get_geometry_argument(argument=spatial_extent,valid_geojson_types=valid_geojson_types,connection=connection) + elif not spatial_extent or (isinstance(spatial_extent, dict) and spatial_extent.keys() & {"west", "east", "north", "south"}): + pass + else: + valid_geojson_types = [ + "Polygon", "MultiPolygon", "Feature", "FeatureCollection" + ] + spatial_extent = _get_geometry_argument(argument=spatial_extent, valid_geojson_types=valid_geojson_types, + connection=connection) arguments = { 'id': collection_id,