Skip to content
Snippets Groups Projects
Commit b09b01e2 authored by Victor Poughon's avatar Victor Poughon
Browse files

DOC: update Python UpdateParameters corner case

parent 67c1747b
Branches
Tags
No related merge requests found
......@@ -387,43 +387,10 @@ happens, this documentation will report the OTB version that fixes the issue.
Calling UpdateParameters()
^^^^^^^^^^^^^^^^^^^^^^^^^^
These wrappers are made as a mirror of the C++ API, so there is a function
``UpdateParameters()``. Its role is to update parameters that depend on others.
It is called at least once at the beginning of ``Execute()``.
In command line and GUI launchers, this functions gets called each time a
parameter of the application is modified. In Python, this mechanism is not
automated: there are cases where you may have to call it yourself.
Let's take an example with the application ``PolygonClassStatictics``. In this
application, the choices available in the parameter ``field`` depend on the list
of fields actually present in the vector file ``vec``. If you try to set the
parameters ``vec`` and ``field``, you will get an error:
.. code-block:: python
import otbApplication as otb
app = otb.Registry.CreateApplication("PolygonClassStatistics")
app.SetParameterString("vec","../../src/OTB-Data/Input/Classification/variousVectors.sqlite")
app.SetParameterString("field", "label")
::
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gpasero/Projet_OTB/build/OTB/lib/otb/python/otbApplication.py", line 897, in SetParameterString
def SetParameterString(self, *args): return _otbApplication.Application_SetParameterString(self, *args)
RuntimeError: Exception thrown in otbApplication Application_SetParameterString: /home/gpasero/Projet_OTB/src/OTB/Modules/Wrappers/ApplicationEngine/src/otbWrapperListViewParameter.cxx:141:
itk::ERROR: ListViewParameter(0x149da10): Cannot find label
The error says that the choice ``label`` is not recognized, because ``UpdateParameters()``
was not called after setting the vector file. The solution is to call it before
setting the ``field`` parameter:
.. code-block:: python
app.UpdateParameters()
app.SetParameterString("field", "label")
``UpdateParameters()`` is available to the Python API. But in normal use, it
does not need to be called manually. From OTB 7.0.0 and later, it is called
automatically after each call to ``SetParameter*()`` methods. With previous versions
of OTB you may need to call it after setting a parameter.
No metadata in NumPy arrays
^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment