Skip to content

Commit 8644c09

Browse files
committed
Issue #104 add docs on how to reconstruct read_vector for old workflows
1 parent 60be18f commit 8644c09

File tree

2 files changed

+57
-5
lines changed

2 files changed

+57
-5
lines changed

docs/cookbook/tricks.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,51 @@ For example:
8080
8181
# `create_job` with URL to JSON file
8282
job = connection.create_job("https://jsonbin.example/my/process-graph.json")
83+
84+
85+
.. _legacy_read_vector:
86+
87+
88+
Legacy ``read_vector`` usage
89+
----------------------------
90+
91+
In versions up to 0.35.0 of the openEO Python client library,
92+
there was an old, deprecated feature in geometry handling
93+
of :py:class:`~openeo.rest.datacube.DataCube` methods like
94+
:py:meth:`~openeo.rest.datacube.DataCube.aggregate_spatial()` and
95+
:py:meth:`~openeo.rest.datacube.DataCube.mask_polygon()`
96+
where you could pass a *backend-side* path as ``geometries``, e.g.:
97+
98+
.. code-block:: python
99+
100+
cube = cube.aggregate_spatial(
101+
geometries="/backend/path/to/geometries.json",
102+
reducer="mean"
103+
)
104+
105+
The client would handle this by automatically adding a ``read_vector`` process
106+
in the process graph, with that path as argument, to instruct the backend to load the geometries from there.
107+
This ``read_vector`` process was however a backend-specific, experimental and now deprecated process.
108+
Moreover, it assumes that the user has access to (or at least knowledge of) the backend's file system,
109+
which violates the openEO principle of abstracting away backend-specific details.
110+
111+
In version 0.36.0, this old deprecated ``read_vector`` feature has been *removed*,
112+
to allow other and better convenience functionality
113+
when providing a string in the ``geometries`` argument:
114+
e.g. load from a URL with standard process ``load_url``,
115+
or load GeoJSON from a local clientside path.
116+
117+
If your workflow however depends on the old, deprecated ``read_vector`` functionality,
118+
it is possible to reconstruct that by manually adding a ``read_vector`` process in your workflow,
119+
for example as follows:
120+
121+
.. code-block:: python
122+
123+
from openeo.processes import process
124+
125+
cube = cube.aggregate_spatial(
126+
geometries=process("read_vector", filename="/backend/path/to/geometries.json"),
127+
reducer="mean"
128+
)
129+
130+
Note that this is also works with older versions of the openEO Python client library.

openeo/rest/datacube.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,9 @@ def filter_spatial(
621621
.. versionchanged:: 0.36.0
622622
Support passing a URL as ``geometries`` argument, which will be loaded with the ``load_url`` process.
623623
624-
.. versionchanged:: 0.36.0
625-
Support for passing a backend-side path as ``geometries`` argument was removed.
624+
.. versionchanged:: 0.36.0
625+
Support for passing a backend-side path as ``geometries`` argument was removed
626+
(also see :ref:`legacy_read_vector`).
626627
Instead, it's possible to provide a client-side path to a GeoJSON file
627628
(which will be loaded client-side to get the geometries as GeoJSON construct).
628629
"""
@@ -1188,7 +1189,8 @@ def aggregate_spatial(
11881189
Support passing a URL as ``geometries`` argument, which will be loaded with the ``load_url`` process.
11891190
11901191
.. versionchanged:: 0.36.0
1191-
Support for passing a backend-side path as ``geometries`` argument was removed.
1192+
Support for passing a backend-side path as ``geometries`` argument was removed
1193+
(also see :ref:`legacy_read_vector`).
11921194
Instead, it's possible to provide a client-side path to a GeoJSON file
11931195
(which will be loaded client-side to get the geometries as GeoJSON construct).
11941196
"""
@@ -1536,7 +1538,8 @@ def apply_polygon(
15361538
Support passing a URL as ``geometries`` argument, which will be loaded with the ``load_url`` process.
15371539
15381540
.. versionchanged:: 0.36.0
1539-
Support for passing a backend-side path as ``geometries`` argument was removed.
1541+
Support for passing a backend-side path as ``geometries`` argument was removed
1542+
(also see :ref:`legacy_read_vector`).
15401543
Instead, it's possible to provide a client-side path to a GeoJSON file
15411544
(which will be loaded client-side to get the geometries as GeoJSON construct).
15421545
"""
@@ -2047,7 +2050,8 @@ def mask_polygon(
20472050
Support passing a URL as ``geometries`` argument, which will be loaded with the ``load_url`` process.
20482051
20492052
.. versionchanged:: 0.36.0
2050-
Support for passing a backend-side path as ``geometries`` argument was removed.
2053+
Support for passing a backend-side path as ``geometries`` argument was removed
2054+
(also see :ref:`legacy_read_vector`).
20512055
Instead, it's possible to provide a client-side path to a GeoJSON file
20522056
(which will be loaded client-side to get the geometries as GeoJSON construct).
20532057
"""

0 commit comments

Comments
 (0)