Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #678 support shapely in load collection spatial extent #682

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4db1718
issue #678 support shapely in load collection spatial extent
ElienVandermaesenVITO Dec 10, 2024
146f35e
issue #678 support shapely in load collection spatial extent
ElienVandermaesenVITO Dec 10, 2024
ef50a25
issue #678 support shapely in load collection spatial extent
ElienVandermaesenVITO Dec 10, 2024
8cadb84
issue #678 support shapely and local path in load collection spatial …
ElienVandermaesenVITO Dec 13, 2024
d277011
issue #678 support shapely and local path in load collection spatial …
ElienVandermaesenVITO Dec 16, 2024
81431c2
issue #678 support shapely and local path in load collection, make ch…
ElienVandermaesenVITO Dec 19, 2024
a64ce16
issue #678 correct valid types of geojson types in filter_spatial
ElienVandermaesenVITO Jan 2, 2025
a6c6533
issue #693 solve merge conflicts
ElienVandermaesenVITO Jan 8, 2025
db6bbb8
issue #693 solve merge conflicts
ElienVandermaesenVITO Jan 8, 2025
e9ec44d
issue #678 improve documentation
ElienVandermaesenVITO Jan 9, 2025
d83b3c8
Merge remote-tracking branch 'origin/master' into issue678-load_colle…
soxofaan Jan 16, 2025
ac11868
Issue #678/#682 further finetuning
soxofaan Jan 16, 2025
adf4f4c
fixup! Issue #678/#682 further finetuning
soxofaan Jan 16, 2025
a6f1cf9
fixup! fixup! Issue #678/#682 further finetuning
soxofaan Jan 16, 2025
45f0215
Issue #678/#682 more test coverage of `spatial_extent` handling
soxofaan Jan 17, 2025
8a3ba03
fixup! Issue #678/#682 more test coverage of `spatial_extent` handling
soxofaan Jan 17, 2025
0b486a4
Issue #678/#682 more tests for load_stac spatial_extent handling
soxofaan Jan 17, 2025
1cd1cd2
Issue #678/#682 finetune TestDataCube tests
soxofaan Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +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()`/`load_stac()`: add support for Shapely objects and loading GeoJSON from a local path. ([#678](https://github.com/Open-EO/openeo-python-client/issues/678))

### Changed

Expand Down
3 changes: 3 additions & 0 deletions openeo/api/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ def schema_supports(schema: Union[dict, List[dict]], type: str, subtype: Optiona
elif isinstance(actual_type, list):
if type not in actual_type:
return False
elif actual_type is None:
# Without explicit "type", anything is accepted
return True
else:
raise ValueError(actual_type)
if subtype:
Expand Down
2 changes: 1 addition & 1 deletion openeo/rest/_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def setup_collection(
json={
"id": collection_id,
# define temporal and band dim
"cube:dimensions": {"t": {"type": "temporal"}, "bands": {"type": "bands"}},
"cube:dimensions": cube_dimensions,
},
)
return self
Expand Down
21 changes: 17 additions & 4 deletions openeo/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def datacube_from_json(self, src: Union[str, Path], parameters: Optional[dict] =
def load_collection(
self,
collection_id: Union[str, Parameter],
spatial_extent: Union[Dict[str, float], Parameter, None] = None,
spatial_extent: Union[dict, Parameter, shapely.geometry.base.BaseGeometry, str, Path, None] = None,
temporal_extent: Union[Sequence[InputDate], Parameter, str, None] = None,
bands: Union[Iterable[str], Parameter, str, None] = None,
properties: Union[
Expand All @@ -1269,7 +1269,14 @@ def load_collection(
Load a DataCube by collection id.

:param collection_id: image collection identifier
:param spatial_extent: limit data to specified bounding box or polygons
:param spatial_extent: limit data to specified bounding box or polygons. Can be provided in different ways:
- a bounding box dictionary
- a Shapely geometry object
- a GeoJSON-style dictionary
- a path (as :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 URL to a publicly accessible GeoJSON document
- a :py:class:`~openeo.api.process.Parameter` instance.
: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 All @@ -1288,6 +1295,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
Argument ``spatial_extent``: add support for passing a Shapely geometry or a local path to a GeoJSON file.
"""
return DataCube.load_collection(
collection_id=collection_id,
Expand Down Expand Up @@ -1346,7 +1356,7 @@ def load_result(
def load_stac(
self,
url: str,
spatial_extent: Union[Dict[str, float], Parameter, None] = None,
spatial_extent: Union[dict, Parameter, shapely.geometry.base.BaseGeometry, str, Path, None] = None,
temporal_extent: Union[Sequence[InputDate], Parameter, str, None] = None,
bands: Union[Iterable[str], Parameter, str, None] = None,
properties: Optional[Dict[str, Union[str, PGNode, Callable]]] = None,
Expand Down Expand Up @@ -1448,6 +1458,9 @@ def load_stac(
.. versionchanged:: 0.23.0
Argument ``temporal_extent``: add support for year/month shorthand notation
as discussed at :ref:`date-shorthand-handling`.

.. versionchanged:: 0.37.0
Argument ``spatial_extent``: add support for passing a Shapely geometry or a local path to a GeoJSON file.
"""
return DataCube.load_stac(
url=url,
Expand Down Expand Up @@ -1553,7 +1566,7 @@ def load_geojson(
return VectorCube.load_geojson(connection=self, data=data, properties=properties)

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

Expand Down
Loading
Loading