Skip to content

Commit

Permalink
issue #678 support shapely and local path in load collection spatial …
Browse files Browse the repository at this point in the history
…extent
  • Loading branch information
ElienVandermaesenVITO authored and soxofaan committed Jan 17, 2025
1 parent aebdf69 commit 7acf9c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add support for `log_level` in `create_job()` and `execute_job()` ([#704](https://github.com/Open-EO/openeo-python-client/issues/704))
- Add initial support for "geometry" dimension type in `CubeMetadata` ([#705](https://github.com/Open-EO/openeo-python-client/issues/705))
- Add support for parameterized `bands` argument in `load_stac()`
- 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

Expand Down
1 change: 1 addition & 0 deletions openeo/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,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.
Expand Down
14 changes: 9 additions & 5 deletions openeo/rest/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -192,11 +193,14 @@ def load_collection(
"Unexpected parameterized `spatial_extent` in `load_collection`:"
f" expected schema compatible 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,
Expand Down

0 comments on commit 7acf9c7

Please sign in to comment.