2013/12/27

Update: Semi-Automatic Classification Plugin v. 2.3.0

I have released a major update for the Semi-Automatic Classification Plugin for QGIS 2.0, version 2.3.0.

This is the changelog:
-new Pre processing tab with utilities
-Pre processing tab: clip multiple rasters at once with coordinates or shapefile
-Pre processing tab: Landsat (4, 5, 7, and 8) utility for automatic conversion
to TOA Reflectance and At-Satellite Brightness Temperature, and optionally DOS1
atmosperic correction
-Post processing tab: classification report in pixel, percentage and area
-added language checkbox for switching between English and locale (default
English)
-Land cover change calculation now uses SAGA command changedetection
-bug fixing

This version features a new Pre processing tab with utilities for preparing raster bands to classification.
In particular, I have added the ability to clip multiple raster at once, using coordinates or a shapefile.
Clip multiple rasters tab

Also, a new tab allows for the automatic conversion of Landsat bands (Landsat 4, 5, 7, and 8) to TOA Reflectance and At-Satellite Brightness Temperature (for thermal bands). Also, it allows for a simple atmospheric correction using the DOS1 method (Dark Object Subtraction 1), which is an image-based technique.
It requires the metadata file (MTL.txt) which is provided with Landsat images. This process automatically convert every .tif file that is found in a defined directory, if the file name ends with a band number. For more information about the conversion equations, see here.
Landsat tab

A new Post processing tab allows for the creation of a report of land cover classification,  providing the pixel count, the percentage and area of each class. This is also available as option during the classification process.
Classification report tab

Finally, the land cover change calculation now uses SAGA command changedetection, which is rapider than the previous python code.
The updated Semi-Automatic Classification Plugin is already available through the QGIS repository, or can be downloaded here.

9 comments:

  1. Dear Luca,
    First excuse me if this is not the right channel to submit bugs of your Semi-Automatic Classification Plugin but I'm having an issue with your plugin that you may be interested in checking out.

    I'm trying to clip a set of Landsat 8 layers using your "Clip Multiple Rasters" tool but after trying several times using different folders I'm still getting an error related with the location of the raster layers.

    I'm using it on OS X 10.9 with QGIS 2.2 (KyngChaos version) and here I is the error I'm getting:

    GDAL provider: Cannot open GDAL dataset /Volumes/Win2TB/SIG/Azuero/LC80120552014029LGN00_converted_crop/clip_RT_LC80120552014029LGN00_B7.tif: `/Volumes/Win2TB/SIG/Azuero/LC80120552014029LGN00_converted_crop/clip_RT_LC80120552014029LGN00_B7.tif' does not exist in the file system, and is not recognised as a supported dataset name.
    Raster layer: Provider is not valid (provider: gdal, URI: /Volumes/Win2TB/SIG/Azuero/LC80120552014029LGN00_converted_crop/clip_RT_LC80120552014029LGN00_B7.tif

    The original files (the ones that want to be clipped) are in:
    /Volumes/Win2TB/SIG/Azuero/LC80120552014029LGN00_converted/

    I want to save the clipped files to:
    /Volumes/Win2TB/SIG/Azuero/LC80120552014029LGN00_converted_crop/

    The raster files are named in this fashion:
    RT_LC80120552014029LGN00_B*.tif

    Thanks!

    ReplyDelete
    Replies
    1. Dear Guillermo,
      thank you for reporting this issue.
      It seems to be related to GDAL. Could you please copy the log file as explained here
      http://fromgistors.blogspot.com/p/ask-for-help.html
      However, you could try to install QGIS and GDAL again.
      If you still have the problem, you could use the virtual machine Semi-Automatic OS http://fromgistors.blogspot.com/p/semi-automatic-os.html

      Delete
    2. Thanks for your response Luca,
      I reinstalled both QGIS and GDAL 1.10 and I'm still getting the error.
      The log after the error is:

      An error has occured while executing Python code:

      Traceback (most recent call last):
      File "/Users/gds506/.qgis2/python/plugins/SemiAutomaticClassificationPlugin/semiautomaticclassificationplugin.py", line 3648, in clipRasters
      if self.logSttngVal == "Yes": self.logToFile(str(inspect.stack()[0][3])+ " " + self.lineOfCode(), " rasters to be clipped" + str(tc))
      NameError: global name 'tc' is not defined

      Python version:
      2.7.5 (default, Aug 25 2013, 00:04:04)
      [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]


      QGIS version:
      2.2.0-Valmiera Valmiera,

      Python path: ['/Users/gds506/.qgis2/python/plugins/processing', '/Users/gds506/.qgis2/python/plugins/LecoS', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', u'/Users/gds506/.qgis2/python', u'/Users/gds506/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/B/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Python/2.7/site-packages/matplotlib-override', '/Library/Frameworks/GDAL.framework/Versions/1.10/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/PIL', '/Users/gds506/.qgis2/python/plugins/mmqgis/forms', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools']

      Delete
    3. I'm sorry... this is the content of the log file:
      Date Function Message
      2014-04-27 19.32.02.556376 logCheckbox 631 LOG ACTIVE SemiAutomaticClass Version 2.5.2 - QGIS v. 20200 - OS posix
      2014-04-27 19.32.10.302276 run 570 CLOSE SESSION
      2014-04-27 19.32.35.293223 refreshRasterLayer 883 raster layers refreshed
      2014-04-27 19.32.35.299037 refreshShapeLayer 908 shape layers refreshed
      2014-04-27 19.32.35.305226 refreshShapeClip 3628 shape layers refreshed
      2014-04-27 19.32.35.310364 refreshClassificationLayer 4174 classification layers refreshed
      2014-04-27 19.32.35.316040 refreshReferenceLayer 4195 reference layers refreshed
      2014-04-27 19.32.35.324175 refreshClassificationReferenceLayer 4283 reference classification layers refreshed
      2014-04-27 19.32.35.330349 refreshNewClassificationLayer 4296 new classification layers refreshed
      2014-04-27 19.32.35.338089 rasterBandName 3263 raster band name checklist created
      2014-04-27 19.32.35.343162 rasterNameList 3544 raster name checklist created
      2014-04-27 19.34.08.191253 run 558 OPEN SESSION SemiAutomaticClass Version 2.5.2 - QGIS v. 20200 - OS posix
      2014-04-27 19.34.08.259219 rasterBandName 3263 raster band name checklist created
      2014-04-27 19.34.08.259833 rasterNameList 3544 raster name checklist created
      2014-04-27 19.34.11.837927 selectAllRasters 3572 all rasters clicked
      2014-04-27 19.34.13.413101 refreshShapeClip 3628 shape layers refreshed
      2014-04-27 20.07.28.534330 run 570 CLOSE SESSION
      2014-04-27 20.07.37.018565 run 558 OPEN SESSION SemiAutomaticClass Version 2.5.2 - QGIS v. 20200 - OS posix
      2014-04-27 20.07.37.044578 rasterBandName 3263 raster band name checklist created
      2014-04-27 20.07.37.045162 rasterNameList 3544 raster name checklist created
      2014-04-27 20.07.53.683673 testSAGA 755 ERROR

      Delete
    4. I am sorry but I don't see the clipping part of the log file.
      You should clear the Log file in the tab settings, activate the log file, then try the clipping operation, and finally deactivate the logging.
      Thus there should be only the clipping part of the log file.
      Thank you.

      Delete
  2. Thanks for your response Luca,
    Following the steps of the link you posted I generated the log file again. These are its contents doing all the steps and getting the "Clip Multiple Rasters" error:

    Date Function Message
    2014-04-28 20.27.35.819021 run 570 CLOSE SESSION
    2014-04-28 20.27.55.012814 refreshRasterLayer 883 raster layers refreshed
    2014-04-28 20.27.55.017234 refreshShapeLayer 908 shape layers refreshed
    2014-04-28 20.27.55.021681 refreshShapeClip 3628 shape layers refreshed
    2014-04-28 20.27.55.026676 refreshClassificationLayer 4174 classification layers refreshed
    2014-04-28 20.27.55.031130 refreshReferenceLayer 4195 reference layers refreshed
    2014-04-28 20.27.55.035594 refreshClassificationReferenceLayer 4283 reference classification layers refreshed
    2014-04-28 20.27.55.040199 refreshNewClassificationLayer 4296 new classification layers refreshed
    2014-04-28 20.27.55.045849 rasterBandName 3263 raster band name checklist created
    2014-04-28 20.27.55.050577 rasterNameList 3544 raster name checklist created
    2014-04-28 20.28.36.629437 run 558 OPEN SESSION SemiAutomaticClass Version 2.5.2 - QGIS v. 20200 - OS posix
    2014-04-28 20.28.36.686755 rasterBandName 3263 raster band name checklist created
    2014-04-28 20.28.36.687381 rasterNameList 3544 raster name checklist created
    2014-04-28 20.28.42.218016 selectAllRasters 3572 all rasters clicked
    2014-04-28 20.28.43.939545 refreshShapeClip 3628 shape layers refreshed
    2014-04-28 20.29.00.887471 logCheckbox 634 LOG DISABLED

    I've tried the same steps on the Ubuntu virtual machine and on the Windows QGIS version and in both it works fine. The problem only happens in the QGIS OS X version.

    ReplyDelete
    Replies
    1. I think it is a problem related to QGIS or GDAL installation in OS X.
      Unfortunately, I have not a OS X machine for testing.
      However, I'll try to understand the cause of your problem.
      Thank you very much for your feedback.

      Delete
  3. I had the same problem with the error "NameError: global name 'tc' is not defined". I have just commented out the rows in the file "semiautomaticclassificationplugin.py", which included "(tc)". The lines are not as important, they are only log commands.
    After the plugin working again. After this, don't update the plugin.


    "Traceback (most recent call last):
    File "/Users/gds506/.qgis2/python/plugins/SemiAutomaticClassificationPlugin/semiautomaticclassificationplugin.py", line 3648, in clipRasters
    if self.logSttngVal == "Yes": self.logToFile(str(inspect.stack()[0][3])+ " " + self.lineOfCode(), " rasters to be clipped" + str(tc))
    NameError: global name 'tc' is not defined"

    ReplyDelete
    Replies
    1. Thank you Marleen for the information.
      I am going to fix this in the next version of the plugin.

      Delete