Discussion:
[otb-users] TrainVectorClassifier: cannot find fieldname in sqlite vector file
k***@gmail.com
2018-10-27 17:50:39 UTC
Permalink
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 otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
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 otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Efi Konstantinidou
2018-10-29 13:57:31 UTC
Permalink
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
Post by k***@gmail.com
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>
.
- 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()
runfile('/home/kleanthis/Projects/BUA_classification/00_SCR/test.py', wdir='/home/kleanthis/Projects/BUA_classification/00_SCR')
Reloaded modules: otbApplication, _otbApplication
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)
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 unsubscribe from this group, send email to
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
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 otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
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 otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
k***@gmail.com
2018-10-30 08:33:30 UTC
Permalink
Thanks a lot for the reply Efi. I was able to run the TrainVectorClassifier
<https://www.orfeo-toolbox.org/CookBook/Applications/app_TrainVectorClassifier.html>
application successfully on the command line. It worked for sqlite and shp
formats.
However i don`t understand why it fails in python. Is it the reading of the
vector file?
Thanks a lot,
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 otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
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 otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Efi Konstantinidou
2018-10-30 09:07:55 UTC
Permalink
Hey Kleanthis, don't know about python but will be trying it in the near
future for my project. We can stay in touch through otb users.
Much success,
Efi
Post by k***@gmail.com
Thanks a lot for the reply Efi. I was able to run the
TrainVectorClassifier
<https://www.orfeo-toolbox.org/CookBook/Applications/app_TrainVectorClassifier.html>
application successfully on the command line. It worked for sqlite and
shp formats.
However i don`t understand why it fails in python. Is it the reading of
the vector file?
Thanks a lot,
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 unsubscribe from this group, send email to
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
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 otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
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 otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Argyros Argyridis
2018-10-30 10:01:53 UTC
Permalink
Dear Kleanthis,

You can try to run the TrainVectorClassifier as a system command through
Python from the os.system command.

Kind regards,
Argyros
Post by Efi Konstantinidou
Hey Kleanthis, don't know about python but will be trying it in the near
future for my project. We can stay in touch through otb users.
Much success,
Efi
Post by k***@gmail.com
Thanks a lot for the reply Efi. I was able to run the
TrainVectorClassifier
<https://www.orfeo-toolbox.org/CookBook/Applications/app_TrainVectorClassifier.html>
application successfully on the command line. It worked for sqlite and
shp formats.
However i don`t understand why it fails in python. Is it the reading of
the vector file?
Thanks a lot,
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 unsubscribe from this group, send email to
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
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 unsubscribe from this group, send email to
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
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 otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
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 otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
k***@gmail.com
2018-10-31 09:17:41 UTC
Permalink
Thanks a lot for the support Efi and Argyros :)
Let stay in touch
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 otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
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 otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...