Hi Kleanthis,

Just a suggestion, have you tried running TrainVectorClassifier on
Monteverdi (gui) first? Had a similar issue with that tool and kind of
better understood the format of the input data through Monteverdi. After
that it also run successfully on the command line - haven't tried python
yet. My 5p.
Liten

On Sat, Oct 27, 2018 at 8:50 PM <[email protected]> wrote:

> Hello everyone,
> Recently i discovered OTB and i am really happy using it. I find some
> difficulties to understand how to use TrainVectorClassifier
> <https://www.orfeo-toolbox.org/CookBook/Applications/app_TrainVectorClassifier.html>
> .
> ----I will present to you each step i performed successfully:
>
>    - At start i downloaded this
>    
> <https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip>
>    shp file from naturalearthdata.com.
>    - After the unzip i opened in QGIS and i saved as sqlite format.
>    - The fields from the attribute table of the shp that i am interested
>    in are: scalerank, labelrank and adm0_dif
>    - I want to train a classifier according to this recipe
>    <https://www.orfeo-toolbox.org/CookBook/recipes/pbclassif.html>
>
> otbcli_TrainVectorClassifier -io.vd samples.sqlite
>                              -cfield CODE
>                              -io.out model.rf
>                              -classifier rf
>                              -feat perimeter area width
>
> ---I wrote this python 2.7 script (*test.py*) in order to run the 
> TrainVectorClassifier application.
>
> import os
>
> os.environ["PYTHONPATH"] =
> "/home/kleanthis/bin/otb/OTB-6.6.0-Linux64/lib/python"
>
>
> input_polygons='/home/kleanthis/Projects/BUA_classification/2_Processing/Obia_experiments/test_sqlite/ne_110m_admin_0_countries.sqlite'
>
>
> import otbApplication
>
> TrainVectorClassifier =
> otbApplication.Registry.CreateApplication("TrainVectorClassifier")
>
> TrainVectorClassifier.SetParameterString('io.vd', input_polygons)
>
> TrainVectorClassifier.SetParameterString('cfield', 'adm0_dif')
>
> TrainVectorClassifier.SetParameterStringList("feat",
> ["labelrank","scalerank"] )
>
> TrainVectorClassifier.SetParameterString("classifier", "rf")
>
> TrainVectorClassifier.SetParameterString("io.out",
> "/home/kleanthis/Projects/classification/2_Processing/Obia_experiments/Label_segments/rfModel.rf")
>
> TrainVectorClassifier.ExecuteAndWriteOutput()
>
>
>
> ---The *error* that pops up is the following one:
>
> runfile('/home/kleanthis/Projects/BUA_classification/00_SCR/test.py', 
> wdir='/home/kleanthis/Projects/BUA_classification/00_SCR')
> Reloaded modules: otbApplication, _otbApplication
> Traceback (most recent call last):
>
>   File "<ipython-input-125-8e6203a4c1cf>", line 1, in <module>
>     runfile('/home/kleanthis/Projects/BUA_classification/00_SCR/test.py', 
> wdir='/home/kleanthis/Projects/BUA_classification/00_SCR')
>
>   File 
> "/home/kleanthis/miniconda3/envs/spyderakos/lib/python2.7/site-packages/spyder_kernels/customize/spydercustomize.py",
>  line 678, in runfile
>     execfile(filename, namespace)
>
>   File 
> "/home/kleanthis/miniconda3/envs/spyderakos/lib/python2.7/site-packages/spyder_kernels/customize/spydercustomize.py",
>  line 98, in execfile
>     builtins.execfile(filename, *where)
>
>   File "/home/kleanthis/Projects/BUA_classification/00_SCR/test.py", line 16, 
> in <module>
>     TrainVectorClassifier.SetParameterString('cfield', 'adm0_dif')
>
>   File 
> "/home/kleanthis/bin/otb/OTB-6.6.0-Linux64/lib/python/otbApplication.py", 
> line 1475, in SetParameterString
>     def SetParameterString(self, *args): return 
> _otbApplication.Application_SetParameterString(self, *args)
>
> RuntimeError: Exception thrown in otbApplication 
> Application_SetParameterString: 
> /home/otbval/dashboard/otb/src/Modules/Wrappers/ApplicationEngine/src/otbWrapperListViewParameter.cxx:141:
> itk::ERROR: ListViewParameter(0x55cb7c94f6f0):* Cannot find adm0_dif*
>
>
> Any advice, suggestion is welcome :)
>
> Thanks in advance,
> Kleanthis
>
>
>
>
>
> --
> --
> Check the OTB FAQ at
> http://www.orfeo-toolbox.org/FAQ.html
>
> You received this message because you are subscribed to the Google
> Groups "otb-users" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/otb-users?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "otb-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to