semiautomaticgit / SemiAutomaticClassificationPlugin

https://fromgistors.blogspot.com/p/semi-automatic-classification-plugin.html
Other
136 stars 50 forks source link

AttributeError: 'str' object has no attribute 'dataProvider' #226

Closed stochastic-sleuth closed 9 months ago

stochastic-sleuth commented 2 years ago

Hi, I am having the following error preventing me from classifying imagery, using spectral angle mapping and a previously created .scp file, after several successful iterations previously in an older SCP version. I am running QGIS 3.16 and SCP 7.10.6 using python 3.9. Please let me know how I can help troubleshoot this error.

Thanks, Jess

2022-06-17T15:26:18 WARNING Traceback (most recent call last): File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/maininterface/classificationTab.py", line 121, in runClassificationAction self.runClassification(bandSetNumber = bndStN, algorithmFilesCheck = algFilesCheck, reportCheck = report, vectorConversion = vector, useMacroclass = macroclass, useLcs = useLcs, useLcsAlgorithm = useLcsAlgorithm, LCSLeaveUnclassified = leaveUnclassified, maskCheckBox = maskC, maskPath = maskPath) File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/maininterface/classificationTab.py", line 212, in runClassification self.applyClassSymbology(c, cfg.macroclassCheck, cfg.qmlFl, sL) File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/maininterface/classificationTab.py", line 282, in applyClassSymbology cfg.utls.rasterSymbol(classificationRaster, signatureList, macroclassCheck) File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/core/utils.py", line 657, in rasterSymbol lR = cfg.qgisCoreSCP.QgsPalettedRasterRenderer(classLayer.dataProvider(), cLB, cL) AttributeError: 'str' object has no attribute 'dataProvider'

SemiAutomatic_python_error.txt

semiautomaticgit commented 2 years ago

Hi @stochastic-sleuth , it seems an installation issue.

You can try to follow this guide https://semiautomaticclassificationmanual.readthedocs.io/en/latest/faq.html#i-have-installation-issues-on-mac-os-how-can-i-install-scp-on-mac-os or you can continue to use the previous SCP version 6 https://semiautomaticclassificationmanual.readthedocs.io/en/latest/faq.html#can-i-use-the-previous-version-6-of-scp

stochastic-sleuth commented 1 year ago

Thanks for your response. I found your guide very helpful, but I am unsure how to clean up my paths and I think that may be what is getting me stuck. I have tried a fresh install of QGIS 3.22 and ESA SNAP on a newly wiped PC and I am still having issues. Could you please help me understand how I can try to set up clean paths needed for this? I look forward to using this tool extensively for research thanks again.

An error has occurred while executing Python code:AttributeError: 'str' object has no attribute 'dataProvider'Traceback (most recent call last):File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\classificationTab.py", line 121, in runClassificationActionself.runClassification(bandSetNumber = bndStN, algorithmFilesCheck = algFilesCheck, reportCheck = report, vectorConversion = vector, useMacroclass = macroclass, useLcs = useLcs, useLcsAlgorithm = useLcsAlgorithm, LCSLeaveUnclassified = leaveUnclassified, maskCheckBox = maskC, maskPath = maskPath)File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\classificationTab.py", line 212, in runClassificationself.applyClassSymbology(c, cfg.macroclassCheck, cfg.qmlFl, sL)File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\classificationTab.py", line 282, in applyClassSymbologycfg.utls.rasterSymbol(classificationRaster, signatureList, macroclassCheck)File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\core\utils.py", line 657, in rasterSymbollR = cfg.qgisCoreSCP.QgsPalettedRasterRenderer(classLayer.dataProvider(), cLB, cL)AttributeError: 'str' object has no attribute 'dataProvider'Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]QGIS version: 3.22.8-Białowieża Białowieża, 8d5e9761dfPython

Path:C:/PROGRA~1/QGIS32~1.8/apps/qgisltr/./pythonC:/Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA~1/QGIS32~1.8/apps/qgisltr/./python/plugins C:\PROGRA~1\QGIS32~1.8\bin\python39.zip C:\PROGRA~1\QGIS32~1.8\apps\Python39\DLLs C:\PROGRA~1\QGIS32~1.8\apps\Python39\lib C:\PROGRA~1\QGIS32~1.8\bin C:\PROGRA~1\QGIS32~1.8\apps\Python39 C:\PROGRA~1\QGIS32~1.8\apps\Python39\lib\site-packages C:\PROGRA~1\QGIS32~1.8\apps\Python39\lib\site-packages\win32 C:\PROGRA~1\QGIS32~1.8\apps\Python39\lib\site-packages\win32\lib C:\PROGRA~1\QGIS32~1.8\apps\Python39\lib\site-packages\Pythonwin C:/Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python D:/Channel_width_NAIP

error.txt

semiautomaticgit commented 1 year ago

Hello @stochastic-sleuth , it seems that the gpt executable path (which could be C:/Program Files/snap/bin/gpt.exe depending on SNAP installation) is not defined in SCP settings. Please read https://semiautomaticclassificationmanual.readthedocs.io/en/latest/processingSettingTab.html#external-programs

stochastic-sleuth commented 1 year ago

Thank you so much. In my case I was missing the ".exe" in settings. Your documentation is excellent. Back on my mac, however, I have in /Applications/snap/bin/gpt in my processing settings and am still getting the same error. Does it need to be configured for python? I am running 3.9 and I notice Snap is not compatible with that version.

On Sun, Jul 10, 2022 at 11:56 AM Luca Congedo @.***> wrote:

Hello @stochastic-sleuth https://github.com/stochastic-sleuth , it seems that the gpt executable path (which could be C:/Program Files/snap/bin/gpt.exe depending on SNAP installation) is not defined in SCP settings. Please read https://semiautomaticclassificationmanual.readthedocs.io/en/latest/processingSettingTab.html#external-programs

— Reply to this email directly, view it on GitHub https://github.com/semiautomaticgit/SemiAutomaticClassificationPlugin/issues/226#issuecomment-1179780500, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3VEFYR3W2EVH36GAFXN6TVTMMGHANCNFSM5ZDVRO6A . You are receiving this because you were mentioned.Message ID: <semiautomaticgit/SemiAutomaticClassificationPlugin/issues/226/1179780500@ github.com>

semiautomaticgit commented 1 year ago

Your documentation is excellent.

Thank you, I'm glad that it was useful to you.

Back on my mac, however, I have in /Applications/snap/bin/gpt in my processing settings and am still getting the same error. Does it need to be configured for python? I am running 3.9 and I notice Snap is not compatible with that version.

Setting the gpt path should be sufficient. However, recent versions of QGIS in MacOS have some issues with the installation of SCP. You can try to test if other SCP functions work, otherwise you should try to install a previous version of QGIS such as 3.18

semiautomaticgit commented 9 months ago

I'm closing this because of the new version 8 of SCP. Please reopen it if it is still relevant in the new version. Thank you!