@@ -9,16 +9,16 @@ The ``load_collection`` process
99
1010The most straightforward way to start building your openEO data cube is through the ``load_collection `` process.
1111As mentioned earlier, this is provided by the
12- :meth: `~openeo.rest.connection.Connection.load_collection ` method
13- on a :class: `~openeo.rest.connection.Connection ` object,
14- which produces a :class: `~openeo.rest.datacube.DataCube ` instance.
12+ :py: meth: `~openeo.rest.connection.Connection.load_collection ` method
13+ on a :py: class: `~openeo.rest.connection.Connection ` object,
14+ which produces a :py: class: `~openeo.rest.datacube.DataCube ` instance.
1515For example::
1616
1717 cube = connection.load_collection("SENTINEL2_TOC")
1818
1919While this should cover the majority of use cases,
2020there some cases
21- where one wants to build a :class: `~openeo.rest.datacube.DataCube ` object
21+ where one wants to build a :py: class: `~openeo.rest.datacube.DataCube ` object
2222from something else or something more than just a simple ``load_collection `` process.
2323
2424
@@ -38,7 +38,7 @@ but let's assume there is a parameter "dilation" to fine-tune the cloud mask.
3838Also note that the collection id "SENTINEL2_TOC" is hardcoded in the user-defined process.
3939
4040We can now construct a data cube from this user-defined process
41- with :meth: `~openeo.rest.connection.Connection.datacube_from_process `
41+ with :py: meth: `~openeo.rest.connection.Connection.datacube_from_process `
4242as follows::
4343
4444 cube = connection.datacube_from_process("masked_s2", dilation=10)
@@ -47,7 +47,7 @@ as follows::
4747 cube = cube.filter_temporal("2020-09-01", "2020-09-10")
4848
4949
50- Note that :meth: `~openeo.rest.connection.Connection.datacube_from_process ` can be
50+ Note that :py: meth: `~openeo.rest.connection.Connection.datacube_from_process ` can be
5151used with all kind of processes, not only user-defined processes.
5252For example, while this is not exactly a real EO data use case,
5353it will produce a valid openEO process graph that can be executed::
@@ -60,8 +60,8 @@ it will produce a valid openEO process graph that can be executed::
6060
6161.. _datacube_from_json :
6262
63- Construct DataCube from JSON
64- ==============================
63+ Construct a DataCube from JSON
64+ ===============================
6565
6666openEO process graphs are typically stored and published in JSON format.
6767Most notably, user-defined processes are transferred between openEO client
@@ -81,8 +81,8 @@ and back-end in a JSON structure roughly like in this example::
8181 ...
8282
8383
84- It is possible to construct a :class: `~openeo.rest.datacube.DataCube ` object that corresponds with this
85- process graph with the :meth: `Connection.datacube_from_json <openeo.rest.connection.Connection.datacube_from_json> ` method.
84+ It is possible to construct a :py: class: `~openeo.rest.datacube.DataCube ` object that corresponds with this
85+ process graph with the :py: meth: `Connection.datacube_from_json <openeo.rest.connection.Connection.datacube_from_json> ` method.
8686It can be given one of:
8787
8888 - a raw JSON string,
@@ -99,16 +99,20 @@ The JSON structure should be one of:
9999Some examples
100100---------------
101101
102- Load a :class: `~openeo.rest.datacube.DataCube ` from a raw JSON string, containing a
103- simple "flat graph" representation::
102+ Load a :py:class: `~openeo.rest.datacube.DataCube ` from a raw JSON string, containing a
103+ simple "flat graph" representation:
104+
105+ .. code-block :: python
104106
105107 raw_json = ''' {
106108 "lc": {"process_id": "load_collection", "arguments": {"id": "SENTINEL2_TOC"}},
107109 "ak": {"process_id": "apply_kernel", "arguments": {"data": {"from_node": "lc"}, "kernel": [[1,2,1],[2,5,2],[1,2,1]]}, "result": true}
108110 }'''
109111 cube = connection.datacube_from_json(raw_json)
110112
111- Load from a raw JSON string, containing a mapping with "process_graph" and "parameters"::
113+ Load from a raw JSON string, containing a mapping with "process_graph" and "parameters":
114+
115+ .. code-block :: python
112116
113117 raw_json = ''' {
114118 "parameters": [
@@ -121,42 +125,58 @@ Load from a raw JSON string, containing a mapping with "process_graph" and "para
121125 }'''
122126 cube = connection.datacube_from_json(raw_json)
123127
124- Load directly from a file or URL containing these kind of JSON representations: :
128+ Load directly from a local file or URL containing these kind of JSON representations:
125129
130+ .. code-block :: python
131+
132+ # Local file
126133 cube = connection.datacube_from_json(" path/to/my_udp.json" )
127134
128- cube = connection.datacube_from_json("https://openeo.example/process_graphs/my_udp")
135+ # URL
136+ cube = connection.datacube_from_json(" https://example.com/my_udp.json" )
129137
130138
131139 Parameterization
132140-----------------
133141
134142When the process graph uses parameters, you must specify the desired parameter values
135- at the time of calling :meth: `Connection.datacube_from_json <openeo.rest.connection.Connection.datacube_from_json> `.
143+ at the time of calling :py:meth: `Connection.datacube_from_json <openeo.rest.connection.Connection.datacube_from_json> `.
144+
145+ For example, take this simple toy example of a process graph that takes the sum of 5 and a parameter "increment":
136146
137- For example, take this simple toy example of a process graph that takes the sum of 5 and a parameter "increment"::
147+ .. code-block :: python
138148
139149 raw_json = ''' {"add": {
140150 "process_id": "add",
141151 "arguments": {"x": 5, "y": {"from_parameter": "increment"}},
142152 "result": true
143153 }}'''
144154
145- Trying to build a :class: `~openeo.rest.datacube.DataCube ` from it without specifying parameter values will fail
146- like this::
155+ Trying to build a :py:class: `~openeo.rest.datacube.DataCube ` from it without specifying parameter values will fail
156+ like this:
157+
158+ .. code-block :: pycon
147159
148160 >>> cube = connection.datacube_from_json(raw_json)
149161 ProcessGraphVisitException: No substitution value for parameter 'increment'.
150162
151- Instead, specify the parameter value::
163+ Instead, specify the parameter value:
164+
165+ .. code-block :: pycon
166+ :emphasize-lines: 3
152167
153- >>> cube = connection.datacube_from_json(raw_json, parameters={"increment": 4})
168+ >>> cube = connection.datacube_from_json(
169+ ... raw_json,
170+ ... parameters={"increment": 4},
171+ ... )
154172 >>> cube.execute()
155173 9
156174
157175
158176 Parameters can also be defined with default values, which will be used when they are not specified
159- in the :meth: `Connection.datacube_from_json <openeo.rest.connection.Connection.datacube_from_json> ` call::
177+ in the :py:meth: `Connection.datacube_from_json <openeo.rest.connection.Connection.datacube_from_json> ` call:
178+
179+ .. code-block :: python
160180
161181 raw_json = ''' {
162182 "parameters": [
0 commit comments