Skip to content

Commit d277011

Browse files
issue #678 support shapely and local path in load collection spatial extent
1 parent 8cadb84 commit d277011

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- 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))
13-
- Argument `spatial_extent` in `load_collection` supports type `shapely` and loading geometry from a local path.
13+
- Argument `spatial_extent` in `load_collection` supports Shapely objects and loading GeoJSON from a local path.
1414

1515
### Changed
1616

openeo/rest/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ def load_collection(
12491249
- a path (:py:class:`str` or :py:class:`~pathlib.Path`) to a local, client-side GeoJSON file,
12501250
which will be loaded automatically to get the geometries as GeoJSON construct.
12511251
- a :py:class:`~openeo.api.process.Parameter` instance.
1252+
- a bounding box dictionary
12521253
:param temporal_extent: limit data to specified temporal interval.
12531254
Typically, just a two-item list or tuple containing start and end date.
12541255
See :ref:`filtering-on-temporal-extent-section` for more details on temporal extent handling and shorthand notation.

openeo/rest/datacube.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def load_collection(
164164
- a path (:py:class:`str` or :py:class:`~pathlib.Path`) to a local, client-side GeoJSON file,
165165
which will be loaded automatically to get the geometries as GeoJSON construct.
166166
- a :py:class:`~openeo.api.process.Parameter` instance.
167+
- a bounding box dictionary
167168
:param temporal_extent: limit data to specified temporal interval.
168169
Typically, just a two-item list or tuple containing start and end date.
169170
See :ref:`filtering-on-temporal-extent-section` for more details on temporal extent handling and shorthand notation.
@@ -192,11 +193,14 @@ def load_collection(
192193
"Unexpected parameterized `spatial_extent` in `load_collection`:"
193194
f" expected schema with type 'object' but got {spatial_extent.schema!r}."
194195
)
195-
valid_geojson_types = [
196-
"Polygon", "MultiPolygon", "Feature", "FeatureCollection"
197-
]
198-
if spatial_extent and not (isinstance(spatial_extent, dict) and spatial_extent.keys() & {"west", "east", "north", "south"}):
199-
spatial_extent = _get_geometry_argument(argument=spatial_extent,valid_geojson_types=valid_geojson_types,connection=connection)
196+
elif not spatial_extent or (isinstance(spatial_extent, dict) and spatial_extent.keys() & {"west", "east", "north", "south"}):
197+
pass
198+
else:
199+
valid_geojson_types = [
200+
"Polygon", "MultiPolygon", "Feature", "FeatureCollection"
201+
]
202+
spatial_extent = _get_geometry_argument(argument=spatial_extent, valid_geojson_types=valid_geojson_types,
203+
connection=connection)
200204

201205
arguments = {
202206
'id': collection_id,

0 commit comments

Comments
 (0)