Skip to content

Commit 0794610

Browse files
committed
Merge branch 'issue678-load_collection-support-shapely-geometry-input'
2 parents a907e38 + e1fa369 commit 0794610

File tree

9 files changed

+699
-112
lines changed

9 files changed

+699
-112
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Add support for `log_level` in `create_job()` and `execute_job()` ([#704](https://github.com/Open-EO/openeo-python-client/issues/704))
1515
- Add initial support for "geometry" dimension type in `CubeMetadata` ([#705](https://github.com/Open-EO/openeo-python-client/issues/705))
1616
- Add support for parameterized `bands` argument in `load_stac()`
17+
- Argument `spatial_extent` in `load_collection()`/`load_stac()`: add support for Shapely objects, loading GeoJSON from a local path and loading geometry from GeoJSON/GeoParquet URL. ([#678](https://github.com/Open-EO/openeo-python-client/issues/678))
1718

1819
### Changed
1920

openeo/api/process.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,9 @@ def schema_supports(schema: Union[dict, List[dict]], type: str, subtype: Optiona
467467
elif isinstance(actual_type, list):
468468
if type not in actual_type:
469469
return False
470+
elif actual_type is None:
471+
# Without explicit "type", anything is accepted
472+
return True
470473
else:
471474
raise ValueError(actual_type)
472475
if subtype:

openeo/rest/_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def setup_collection(
153153
json={
154154
"id": collection_id,
155155
# define temporal and band dim
156-
"cube:dimensions": {"t": {"type": "temporal"}, "bands": {"type": "bands"}},
156+
"cube:dimensions": cube_dimensions,
157157
},
158158
)
159159
return self

openeo/rest/connection.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ def datacube_from_json(self, src: Union[str, Path], parameters: Optional[dict] =
12561256
def load_collection(
12571257
self,
12581258
collection_id: Union[str, Parameter],
1259-
spatial_extent: Union[Dict[str, float], Parameter, None] = None,
1259+
spatial_extent: Union[dict, Parameter, shapely.geometry.base.BaseGeometry, str, Path, None] = None,
12601260
temporal_extent: Union[Sequence[InputDate], Parameter, str, None] = None,
12611261
bands: Union[Iterable[str], Parameter, str, None] = None,
12621262
properties: Union[
@@ -1269,7 +1269,14 @@ def load_collection(
12691269
Load a DataCube by collection id.
12701270
12711271
:param collection_id: image collection identifier
1272-
:param spatial_extent: limit data to specified bounding box or polygons
1272+
:param spatial_extent: limit data to specified bounding box or polygons. Can be provided in different ways:
1273+
- a bounding box dictionary
1274+
- a Shapely geometry object
1275+
- a GeoJSON-style dictionary
1276+
- a path (as :py:class:`str` or :py:class:`~pathlib.Path`) to a local, client-side GeoJSON file,
1277+
which will be loaded automatically to get the geometries as GeoJSON construct.
1278+
- a URL to a publicly accessible GeoJSON document
1279+
- a :py:class:`~openeo.api.process.Parameter` instance.
12731280
:param temporal_extent: limit data to specified temporal interval.
12741281
Typically, just a two-item list or tuple containing start and end date.
12751282
See :ref:`filtering-on-temporal-extent-section` for more details on temporal extent handling and shorthand notation.
@@ -1288,6 +1295,9 @@ def load_collection(
12881295
12891296
.. versionchanged:: 0.26.0
12901297
Add :py:func:`~openeo.rest.graph_building.collection_property` support to ``properties`` argument.
1298+
1299+
.. versionchanged:: 0.37.0
1300+
Argument ``spatial_extent``: add support for passing a Shapely geometry or a local path to a GeoJSON file.
12911301
"""
12921302
return DataCube.load_collection(
12931303
collection_id=collection_id,
@@ -1346,7 +1356,7 @@ def load_result(
13461356
def load_stac(
13471357
self,
13481358
url: str,
1349-
spatial_extent: Union[Dict[str, float], Parameter, None] = None,
1359+
spatial_extent: Union[dict, Parameter, shapely.geometry.base.BaseGeometry, str, Path, None] = None,
13501360
temporal_extent: Union[Sequence[InputDate], Parameter, str, None] = None,
13511361
bands: Union[Iterable[str], Parameter, str, None] = None,
13521362
properties: Optional[Dict[str, Union[str, PGNode, Callable]]] = None,
@@ -1448,6 +1458,9 @@ def load_stac(
14481458
.. versionchanged:: 0.23.0
14491459
Argument ``temporal_extent``: add support for year/month shorthand notation
14501460
as discussed at :ref:`date-shorthand-handling`.
1461+
1462+
.. versionchanged:: 0.37.0
1463+
Argument ``spatial_extent``: add support for passing a Shapely geometry or a local path to a GeoJSON file.
14511464
"""
14521465
return DataCube.load_stac(
14531466
url=url,
@@ -1553,7 +1566,7 @@ def load_geojson(
15531566
return VectorCube.load_geojson(connection=self, data=data, properties=properties)
15541567

15551568
@openeo_process
1556-
def load_url(self, url: str, format: str, options: Optional[dict] = None):
1569+
def load_url(self, url: str, format: str, options: Optional[dict] = None) -> VectorCube:
15571570
"""
15581571
Loads a file from a URL
15591572

0 commit comments

Comments
 (0)