Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
b09b01e2
Commit
b09b01e2
authored
5 years ago
by
Victor Poughon
Browse files
Options
Downloads
Patches
Plain Diff
DOC: update Python UpdateParameters corner case
parent
67c1747b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Documentation/Cookbook/rst/PythonAPI.rst
+4
-37
4 additions, 37 deletions
Documentation/Cookbook/rst/PythonAPI.rst
with
4 additions
and
37 deletions
Documentation/Cookbook/rst/PythonAPI.rst
+
4
−
37
View file @
b09b01e2
...
...
@@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment