I get an error when working Classification Erosion tool in Semi-automatic Classification Plugin (SCP). I use QGIS v3.2.2 and SCP v6.2.4.

The tool is not changing the pixels of the raster layer and creates this short report:

**An error has occurred while executing Python code:**
*NameError: name 'd' is not defined 
Traceback (most recent call last):
  File "C:/Users/Sergio/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\erosionTab.py", line 65, in erosionClassificationAction
  File "C:/Users/Sergio/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\erosionTab.py", line 81, in erosionClassification
    sN = cfg.osSCP.path.basename(str(d))
NameError: name 'd' is not defined*

Classification before erosion:

Classification before erosion

  • What isn't working about it specifically? – AWGIS Oct 1 '18 at 15:37
  • Please see the text of the question now with additional comments. – Sergio Oct 1 '18 at 18:44
  • 3
    I'm voting to close this question as off-topic because this plugin is maintained by a specific person/team, this problem should be dealt by them and is outside the scope of this forum. – Hornbydd Oct 1 '18 at 22:10

Variable d doesn't exist and sN is not used anywhere within the file. So, changing that line into comment avoid you to get that error.

I'm not sure if it works but try these:

  1. Open erosionTab.py file in any editor. (C:/Users/Sergio/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\erosionTab.py)
  2. Go to line 81 (sN=cfg.osSCP.path.basename(str(d)))
  3. Change to comment by adding hash # to beginning of the line. (#sN=cfg.osSCP.path.basename(str(d)))
  4. Save the file, re-open QGIS and try to run SCP again.
  • Thank you for all your help. Now the Classification Erosion tool works perfectly. – Sergio Oct 2 '18 at 12:42
  • Reported as a bug on GitHub – Kadir Şahbaz Oct 2 '18 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.