├── ClassAccuracyMain ├── Makefile ├── README.html ├── README.txt ├── __init__.py ├── help │ ├── Makefile │ ├── make.bat │ └── source │ │ ├── conf.py │ │ └── index.rst ├── i18n │ └── af.ts ├── icon.png ├── metadata.txt ├── pb_tool.cfg ├── plugin_upload.py ├── pylintrc ├── resources.qrc ├── resources_rc.py ├── rsgisclassacc.py ├── rsgisclassacc_dialog.py ├── scripts │ ├── compile-strings.sh │ ├── run-env-linux.sh │ └── update-strings.sh └── test │ ├── __init__.py │ ├── qgis_interface.py │ ├── tenbytenraster.asc │ ├── tenbytenraster.asc.aux.xml │ ├── tenbytenraster.keywords │ ├── tenbytenraster.lic │ ├── tenbytenraster.prj │ ├── tenbytenraster.qml │ ├── test_init.py │ ├── test_qgis_environment.py │ ├── test_resources.py │ ├── test_rsgisclassacc_dialog.py │ ├── test_translations.py │ └── utilities.py └── README.md /ClassAccuracyMain/Makefile: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # ClassAccuracyMain 3 | # 4 | # Manually review the accuracy of a classification 5 | # ------------------- 6 | # begin : 2015-08-15 7 | # git sha : $Format:%H$ 8 | # copyright : (C) 2015 by Pete Bunting 9 | # email : pfb@aber.ac.uk 10 | # ***************************************************************************/ 11 | # 12 | #/*************************************************************************** 13 | # * * 14 | # * This program is free software; you can redistribute it and/or modify * 15 | # * it under the terms of the GNU General Public License as published by * 16 | # * the Free Software Foundation; either version 2 of the License, or * 17 | # * (at your option) any later version. * 18 | # * * 19 | # ***************************************************************************/ 20 | 21 | ################################################# 22 | # Edit the following to match your sources lists 23 | ################################################# 24 | 25 | 26 | #Add iso code for any locales you want to support here (space separated) 27 | # default is no locales 28 | # LOCALES = af 29 | LOCALES = 30 | 31 | # If locales are enabled, set the name of the lrelease binary on your system. If 32 | # you have trouble compiling the translations, you may have to specify the full path to 33 | # lrelease 34 | #LRELEASE = lrelease 35 | #LRELEASE = lrelease-qt4 36 | 37 | 38 | # translation 39 | SOURCES = \ 40 | __init__.py \ 41 | rsgisclassacc.py \ 42 | rsgisclassacc_dialog.py 43 | 44 | PLUGINNAME = ClassAccuracyMain 45 | 46 | PY_FILES = \ 47 | rsgisclassacc.py \ 48 | rsgisclassacc_dialog.py \ 49 | __init__.py 50 | 51 | UI_FILES = rsgisclassacc_dialog_base.ui 52 | 53 | EXTRAS = icon.png metadata.txt 54 | 55 | COMPILED_RESOURCE_FILES = resources_rc.py 56 | 57 | PEP8EXCLUDE=pydev,resources_rc.py,conf.py,third_party,ui 58 | 59 | 60 | ################################################# 61 | # Normally you would not need to edit below here 62 | ################################################# 63 | 64 | HELP = help/build/html 65 | 66 | PLUGIN_UPLOAD = $(c)/plugin_upload.py 67 | 68 | RESOURCE_SRC=$(shell grep '^ *@@g;s/.*>//g' | tr '\n' ' ') 69 | 70 | QGISDIR=.qgis2 71 | 72 | default: compile 73 | 74 | compile: $(COMPILED_RESOURCE_FILES) 75 | 76 | %_rc.py : %.qrc $(RESOURCES_SRC) 77 | pyrcc4 -o $*_rc.py $< 78 | 79 | %.qm : %.ts 80 | $(LRELEASE) $< 81 | 82 | test: compile transcompile 83 | @echo 84 | @echo "----------------------" 85 | @echo "Regression Test Suite" 86 | @echo "----------------------" 87 | 88 | @# Preceding dash means that make will continue in case of errors 89 | @-export PYTHONPATH=`pwd`:$(PYTHONPATH); \ 90 | export QGIS_DEBUG=0; \ 91 | export QGIS_LOG_FILE=/dev/null; \ 92 | nosetests -v --with-id --with-coverage --cover-package=. \ 93 | 3>&1 1>&2 2>&3 3>&- || true 94 | @echo "----------------------" 95 | @echo "If you get a 'no module named qgis.core error, try sourcing" 96 | @echo "the helper script we have provided first then run make test." 97 | @echo "e.g. source run-env-linux.sh ; make test" 98 | @echo "----------------------" 99 | 100 | deploy: compile doc transcompile 101 | @echo 102 | @echo "------------------------------------------" 103 | @echo "Deploying plugin to your .qgis2 directory." 104 | @echo "------------------------------------------" 105 | # The deploy target only works on unix like operating system where 106 | # the Python plugin directory is located at: 107 | # $HOME/$(QGISDIR)/python/plugins 108 | mkdir -p $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 109 | cp -vf $(PY_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 110 | cp -vf $(UI_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 111 | cp -vf $(COMPILED_RESOURCE_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 112 | cp -vf $(EXTRAS) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 113 | cp -vfr i18n $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 114 | cp -vfr $(HELP) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/help 115 | 116 | # The dclean target removes compiled python files from plugin directory 117 | # also deletes any .git entry 118 | dclean: 119 | @echo 120 | @echo "-----------------------------------" 121 | @echo "Removing any compiled python files." 122 | @echo "-----------------------------------" 123 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete 124 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname ".git" -prune -exec rm -Rf {} \; 125 | 126 | 127 | derase: 128 | @echo 129 | @echo "-------------------------" 130 | @echo "Removing deployed plugin." 131 | @echo "-------------------------" 132 | rm -Rf $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 133 | 134 | zip: deploy dclean 135 | @echo 136 | @echo "---------------------------" 137 | @echo "Creating plugin zip bundle." 138 | @echo "---------------------------" 139 | # The zip target deploys the plugin and creates a zip file with the deployed 140 | # content. You can then upload the zip file on http://plugins.qgis.org 141 | rm -f $(PLUGINNAME).zip 142 | cd $(HOME)/$(QGISDIR)/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME) 143 | 144 | package: compile 145 | # Create a zip package of the plugin named $(PLUGINNAME).zip. 146 | # This requires use of git (your plugin development directory must be a 147 | # git repository). 148 | # To use, pass a valid commit or tag as follows: 149 | # make package VERSION=Version_0.3.2 150 | @echo 151 | @echo "------------------------------------" 152 | @echo "Exporting plugin to zip package. " 153 | @echo "------------------------------------" 154 | rm -f $(PLUGINNAME).zip 155 | git archive --prefix=$(PLUGINNAME)/ -o $(PLUGINNAME).zip $(VERSION) 156 | echo "Created package: $(PLUGINNAME).zip" 157 | 158 | upload: zip 159 | @echo 160 | @echo "-------------------------------------" 161 | @echo "Uploading plugin to QGIS Plugin repo." 162 | @echo "-------------------------------------" 163 | $(PLUGIN_UPLOAD) $(PLUGINNAME).zip 164 | 165 | transup: 166 | @echo 167 | @echo "------------------------------------------------" 168 | @echo "Updating translation files with any new strings." 169 | @echo "------------------------------------------------" 170 | @chmod +x scripts/update-strings.sh 171 | @scripts/update-strings.sh $(LOCALES) 172 | 173 | transcompile: 174 | @echo 175 | @echo "----------------------------------------" 176 | @echo "Compiled translation files to .qm files." 177 | @echo "----------------------------------------" 178 | @chmod +x scripts/compile-strings.sh 179 | @scripts/compile-strings.sh $(LRELEASE) $(LOCALES) 180 | 181 | transclean: 182 | @echo 183 | @echo "------------------------------------" 184 | @echo "Removing compiled translation files." 185 | @echo "------------------------------------" 186 | rm -f i18n/*.qm 187 | 188 | clean: 189 | @echo 190 | @echo "------------------------------------" 191 | @echo "Removing uic and rcc generated files" 192 | @echo "------------------------------------" 193 | rm $(COMPILED_UI_FILES) $(COMPILED_RESOURCE_FILES) 194 | 195 | doc: 196 | @echo 197 | @echo "------------------------------------" 198 | @echo "Building documentation using sphinx." 199 | @echo "------------------------------------" 200 | cd help; make html 201 | 202 | pylint: 203 | @echo 204 | @echo "-----------------" 205 | @echo "Pylint violations" 206 | @echo "-----------------" 207 | @pylint --reports=n --rcfile=pylintrc . || true 208 | @echo 209 | @echo "----------------------" 210 | @echo "If you get a 'no module named qgis.core' error, try sourcing" 211 | @echo "the helper script we have provided first then run make pylint." 212 | @echo "e.g. source run-env-linux.sh ; make pylint" 213 | @echo "----------------------" 214 | 215 | 216 | # Run pep8 style checking 217 | #http://pypi.python.org/pypi/pep8 218 | pep8: 219 | @echo 220 | @echo "-----------" 221 | @echo "PEP8 issues" 222 | @echo "-----------" 223 | @pep8 --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude $(PEP8EXCLUDE) . || true 224 | @echo "-----------" 225 | @echo "Ignored in PEP8 check:" 226 | @echo $(PEP8EXCLUDE) 227 | -------------------------------------------------------------------------------- /ClassAccuracyMain/README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Plugin Builder Results

4 | 5 | Congratulations! You just built a plugin for QGIS!

6 | 7 |
8 | Your plugin ClassAccuracyMain was created in:
9 |   /Users/pete/Documents/Research/Development/ClassAccuracy/ClassAccuracyMain 10 |

11 | Your QGIS plugin directory is located at:
12 |   /Users/pete/.qgis2/python/plugins 13 |

14 |

What's Next

15 |
    16 |
  1. In your plugin directory, compile the resources file using pyrcc4 (simply run make if you have automake or use pb_tool) 17 |
  2. Test the generated sources using make test (or run tests from your IDE) 18 |
  3. Copy the entire directory containing your new plugin to the QGIS plugin directory (see Notes below) 19 |
  4. Test the plugin by enabling it in the QGIS plugin manager 20 |
  5. Customize it by editing the implementation file rsgisclassacc.py 21 |
  6. Create your own custom icon, replacing the default icon.png 22 |
  7. Modify your user interface by opening rsgisclassacc_dialog_base.ui in Qt Designer 23 |
24 | Notes: 25 |
    26 |
  • You can use the Makefile to compile and deploy when you 27 | make changes. This requires GNU make (gmake). The Makefile is ready to use, however you 28 | will have to edit it to add addional Python source files, dialogs, and translations. 29 |
  • You can also use pb_tool to compile and deploy your plugin. Tweak the pb_tool.cfg file included with your plugin as you add files. Install pb_tool using 30 | pip or easy_install. See http://loc8.cc/pb_tool for more information. 31 |
32 |
33 |
34 |

35 | For information on writing PyQGIS code, see http://loc8.cc/pyqgis_resources for a list of resources. 36 |

37 |
38 | GeoApt LLC 39 | ©2011-2015 GeoApt LLC - geoapt.com 40 | 41 | 42 | -------------------------------------------------------------------------------- /ClassAccuracyMain/README.txt: -------------------------------------------------------------------------------- 1 | Plugin Builder Results 2 | 3 | Your plugin ClassAccuracyMain was created in: 4 | /Users/pete/Documents/Research/Development/ClassAccuracy/ClassAccuracyMain 5 | 6 | Your QGIS plugin directory is located at: 7 | /Users/pete/.qgis2/python/plugins 8 | 9 | What's Next: 10 | 11 | * Copy the entire directory containing your new plugin to the QGIS plugin 12 | directory 13 | 14 | * Compile the resources file using pyrcc4 15 | 16 | * Run the tests (``make test``) 17 | 18 | * Test the plugin by enabling it in the QGIS plugin manager 19 | 20 | * Customize it by editing the implementation file: ``rsgisclassacc.py`` 21 | 22 | * Create your own custom icon, replacing the default icon.png 23 | 24 | * Modify your user interface by opening ClassAccuracyMain.ui in Qt Designer 25 | 26 | * You can use the Makefile to compile your Ui and resource files when 27 | you make changes. This requires GNU make (gmake) 28 | 29 | For more information, see the PyQGIS Developer Cookbook at: 30 | http://www.qgis.org/pyqgis-cookbook/index.html 31 | 32 | (C) 2011-2014 GeoApt LLC - geoapt.com 33 | Git revision : $Format:%H$ 34 | -------------------------------------------------------------------------------- /ClassAccuracyMain/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | ClassAccuracyMain 5 | A QGIS plugin 6 | Manually review the accuracy of a classification 7 | ------------------- 8 | begin : 2015-08-15 9 | copyright : (C) 2015 by Pete Bunting 10 | email : pfb@aber.ac.uk 11 | git sha : $Format:%H$ 12 | ***************************************************************************/ 13 | 14 | /*************************************************************************** 15 | * * 16 | * This program is free software; you can redistribute it and/or modify * 17 | * it under the terms of the GNU General Public License as published by * 18 | * the Free Software Foundation; either version 2 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | ***************************************************************************/ 22 | This script initializes the plugin, making it known to QGIS. 23 | """ 24 | 25 | 26 | # noinspection PyPep8Naming 27 | def classFactory(iface): # pylint: disable=invalid-name 28 | """Load ClassAccuracyMain class from file ClassAccuracyMain. 29 | 30 | :param iface: A QGIS interface instance. 31 | :type iface: QgsInterface 32 | """ 33 | # 34 | from .rsgisclassacc import ClassAccuracyMain 35 | return ClassAccuracyMain(iface) 36 | -------------------------------------------------------------------------------- /ClassAccuracyMain/help/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/template_class.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/template_class.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/template_class" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/template_class" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /ClassAccuracyMain/help/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | if NOT "%PAPER%" == "" ( 11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 12 | ) 13 | 14 | if "%1" == "" goto help 15 | 16 | if "%1" == "help" ( 17 | :help 18 | echo.Please use `make ^` where ^ is one of 19 | echo. html to make standalone HTML files 20 | echo. dirhtml to make HTML files named index.html in directories 21 | echo. singlehtml to make a single large HTML file 22 | echo. pickle to make pickle files 23 | echo. json to make JSON files 24 | echo. htmlhelp to make HTML files and a HTML help project 25 | echo. qthelp to make HTML files and a qthelp project 26 | echo. devhelp to make HTML files and a Devhelp project 27 | echo. epub to make an epub 28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 29 | echo. text to make text files 30 | echo. man to make manual pages 31 | echo. changes to make an overview over all changed/added/deprecated items 32 | echo. linkcheck to check all external links for integrity 33 | echo. doctest to run all doctests embedded in the documentation if enabled 34 | goto end 35 | ) 36 | 37 | if "%1" == "clean" ( 38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 39 | del /q /s %BUILDDIR%\* 40 | goto end 41 | ) 42 | 43 | if "%1" == "html" ( 44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 45 | echo. 46 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 47 | goto end 48 | ) 49 | 50 | if "%1" == "dirhtml" ( 51 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 52 | echo. 53 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 54 | goto end 55 | ) 56 | 57 | if "%1" == "singlehtml" ( 58 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 59 | echo. 60 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 61 | goto end 62 | ) 63 | 64 | if "%1" == "pickle" ( 65 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 66 | echo. 67 | echo.Build finished; now you can process the pickle files. 68 | goto end 69 | ) 70 | 71 | if "%1" == "json" ( 72 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 73 | echo. 74 | echo.Build finished; now you can process the JSON files. 75 | goto end 76 | ) 77 | 78 | if "%1" == "htmlhelp" ( 79 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 80 | echo. 81 | echo.Build finished; now you can run HTML Help Workshop with the ^ 82 | .hhp project file in %BUILDDIR%/htmlhelp. 83 | goto end 84 | ) 85 | 86 | if "%1" == "qthelp" ( 87 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 88 | echo. 89 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 90 | .qhcp project file in %BUILDDIR%/qthelp, like this: 91 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\template_class.qhcp 92 | echo.To view the help file: 93 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\template_class.ghc 94 | goto end 95 | ) 96 | 97 | if "%1" == "devhelp" ( 98 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 99 | echo. 100 | echo.Build finished. 101 | goto end 102 | ) 103 | 104 | if "%1" == "epub" ( 105 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 106 | echo. 107 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 108 | goto end 109 | ) 110 | 111 | if "%1" == "latex" ( 112 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 113 | echo. 114 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 115 | goto end 116 | ) 117 | 118 | if "%1" == "text" ( 119 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 120 | echo. 121 | echo.Build finished. The text files are in %BUILDDIR%/text. 122 | goto end 123 | ) 124 | 125 | if "%1" == "man" ( 126 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 127 | echo. 128 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 129 | goto end 130 | ) 131 | 132 | if "%1" == "changes" ( 133 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 134 | echo. 135 | echo.The overview file is in %BUILDDIR%/changes. 136 | goto end 137 | ) 138 | 139 | if "%1" == "linkcheck" ( 140 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 141 | echo. 142 | echo.Link check complete; look for any errors in the above output ^ 143 | or in %BUILDDIR%/linkcheck/output.txt. 144 | goto end 145 | ) 146 | 147 | if "%1" == "doctest" ( 148 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 149 | echo. 150 | echo.Testing of doctests in the sources finished, look at the ^ 151 | results in %BUILDDIR%/doctest/output.txt. 152 | goto end 153 | ) 154 | 155 | :end 156 | -------------------------------------------------------------------------------- /ClassAccuracyMain/help/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ClassAccuracyMain documentation build configuration file, created by 4 | # sphinx-quickstart on Sun Feb 12 17:11:03 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.todo', 'sphinx.ext.pngmath', 'sphinx.ext.viewcode'] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'ClassAccuracyMain' 44 | copyright = u'2013, Pete Bunting' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '0.1' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = [] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_TemplateModuleNames = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'TemplateClassdoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | # The paper size ('letter' or 'a4'). 173 | #latex_paper_size = 'letter' 174 | 175 | # The font size ('10pt', '11pt' or '12pt'). 176 | #latex_font_size = '10pt' 177 | 178 | # Grouping the document tree into LaTeX files. List of tuples 179 | # (source start file, target name, title, author, documentclass [howto/manual]). 180 | latex_documents = [ 181 | ('index', 'ClassAccuracyMain.tex', u'ClassAccuracyMain Documentation', 182 | u'Pete Bunting', 'manual'), 183 | ] 184 | 185 | # The name of an image file (relative to this directory) to place at the top of 186 | # the title page. 187 | #latex_logo = None 188 | 189 | # For "manual" documents, if this is true, then toplevel headings are parts, 190 | # not chapters. 191 | #latex_use_parts = False 192 | 193 | # If true, show page references after internal links. 194 | #latex_show_pagerefs = False 195 | 196 | # If true, show URL addresses after external links. 197 | #latex_show_urls = False 198 | 199 | # Additional stuff for the LaTeX preamble. 200 | #latex_preamble = '' 201 | 202 | # Documents to append as an appendix to all manuals. 203 | #latex_appendices = [] 204 | 205 | # If false, no module index is generated. 206 | #latex_domain_indices = True 207 | 208 | 209 | # -- Options for manual page output -------------------------------------------- 210 | 211 | # One entry per manual page. List of tuples 212 | # (source start file, name, description, authors, manual section). 213 | man_pages = [ 214 | ('index', 'TemplateClass', u'ClassAccuracyMain Documentation', 215 | [u'Pete Bunting'], 1) 216 | ] 217 | -------------------------------------------------------------------------------- /ClassAccuracyMain/help/source/index.rst: -------------------------------------------------------------------------------- 1 | .. ClassAccuracyMain documentation master file, created by 2 | sphinx-quickstart on Sun Feb 12 17:11:03 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to ClassAccuracyMain's documentation! 7 | ============================================ 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | Indices and tables 15 | ================== 16 | 17 | * :ref:`genindex` 18 | * :ref:`modindex` 19 | * :ref:`search` 20 | 21 | -------------------------------------------------------------------------------- /ClassAccuracyMain/i18n/af.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @default 5 | 6 | 7 | Good morning 8 | Goeie more 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ClassAccuracyMain/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remotesensinginfo/classaccuracy/d459cb394773e0fa22128f94a8ec03fa8250aeb3/ClassAccuracyMain/icon.png -------------------------------------------------------------------------------- /ClassAccuracyMain/metadata.txt: -------------------------------------------------------------------------------- 1 | # This file contains metadata for your plugin. Since 2 | # version 2.0 of QGIS this is the proper way to supply 3 | # information about a plugin. The old method of 4 | # embedding metadata in __init__.py will 5 | # is no longer supported since version 2.0. 6 | 7 | # This file should be included when you package your plugin.# Mandatory items: 8 | 9 | [general] 10 | name=ClassAccuracy 11 | qgisMinimumVersion=2.0 12 | qgisMaximumVersion=3.99 13 | description=Manually review the accuracy of a classification 14 | version=0.1 15 | author=Pete Bunting 16 | email=pfb@aber.ac.uk 17 | 18 | 19 | # End of mandatory metadata 20 | 21 | # Recommended items: 22 | 23 | # Uncomment the following line and add your changelog: 24 | # changelog= 25 | 26 | # Tags are comma separated with spaces allowed 27 | tags= 28 | 29 | homepage= 30 | tracker= 31 | repository= 32 | category=Plugins 33 | icon=icon.png 34 | # experimental flag 35 | experimental=False 36 | 37 | # deprecated flag (applies to the whole plugin, not just a single version) 38 | deprecated=False 39 | 40 | -------------------------------------------------------------------------------- /ClassAccuracyMain/pb_tool.cfg: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # ClassAccuracyMain 3 | # 4 | # Configuration file for plugin builder tool (pb_tool) 5 | # ------------------- 6 | # begin : 2015-08-15 7 | # copyright : (C) 2015 by Pete Bunting 8 | # email : pfb@aber.ac.uk 9 | # ***************************************************************************/ 10 | # 11 | #/*************************************************************************** 12 | # * * 13 | # * This program is free software; you can redistribute it and/or modify * 14 | # * it under the terms of the GNU General Public License as published by * 15 | # * the Free Software Foundation; either version 2 of the License, or * 16 | # * (at your option) any later version. * 17 | # * * 18 | # ***************************************************************************/ 19 | # 20 | # 21 | # You can install pb_tool using: 22 | # pip install http://geoapt.net/files/pb_tool.zip 23 | # 24 | # Consider doing your development (and install of pb_tool) in a virtualenv. 25 | # 26 | # For details on setting up and using pb_tool, see: 27 | # http://spatialgalaxy.net/qgis-plugin-development-with-pb_tool 28 | # 29 | # Issues and pull requests here: 30 | # https://github.com/g-sherman/plugin_build_tool: 31 | # 32 | # Sane defaults for your plugin generated by the Plugin Builder are 33 | # already set below. 34 | # 35 | # As you add Python source files and UI files to your plugin, add 36 | # them to the appropriate [files] section below. 37 | 38 | [plugin] 39 | # Name of the plugin. This is the name of the directory that will 40 | # be created in .qgis2/python/plugins 41 | name: ClassAccuracyMain 42 | 43 | [files] 44 | # Python files that should be deployed with the plugin 45 | python_files: __init__.py rsgisclassacc.py rsgisclassacc_dialog.py 46 | 47 | # The main dialog file that is loaded (not compiled) 48 | # main_dialog: rsgisclassacc_dialog_base.ui 49 | 50 | # Other ui files for dialogs you create (these will be compiled) 51 | #compiled_ui_files: 52 | 53 | # Resource file(s) that will be compiled 54 | resource_files: resources.qrc 55 | 56 | # Other files required for the plugin 57 | extras: icon.png metadata.txt 58 | 59 | # Other directories to be deployed with the plugin. 60 | # These must be subdirectories under the plugin directory 61 | extra_dirs: 62 | 63 | # ISO code(s) for any locales (translations), separated by spaces. 64 | # Corresponding .ts files must exist in the i18n directory 65 | locales: 66 | 67 | [help] 68 | # the built help directory that should be deployed with the plugin 69 | dir: help/build/html 70 | # the name of the directory to target in the deployed plugin 71 | target: help 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /ClassAccuracyMain/plugin_upload.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | """This script uploads a plugin package on the server. 4 | Authors: A. Pasotti, V. Picavet 5 | git sha : $TemplateVCSFormat 6 | """ 7 | from __future__ import print_function 8 | 9 | from future import standard_library 10 | standard_library.install_aliases() 11 | from builtins import input 12 | import sys 13 | import getpass 14 | import xmlrpc.client 15 | from optparse import OptionParser 16 | 17 | # Configuration 18 | PROTOCOL = 'http' 19 | SERVER = 'plugins.qgis.org' 20 | PORT = '80' 21 | ENDPOINT = '/plugins/RPC2/' 22 | VERBOSE = False 23 | 24 | 25 | def main(parameters, arguments): 26 | """Main entry point. 27 | 28 | :param parameters: Command line parameters. 29 | :param arguments: Command line arguments. 30 | """ 31 | address = "%s://%s:%s@%s:%s%s" % ( 32 | PROTOCOL, 33 | parameters.username, 34 | parameters.password, 35 | parameters.server, 36 | parameters.port, 37 | ENDPOINT) 38 | # fix_print_with_import 39 | print("Connecting to: %s" % hide_password(address)) 40 | 41 | server = xmlrpc.client.ServerProxy(address, verbose=VERBOSE) 42 | 43 | try: 44 | plugin_id, version_id = server.plugin.upload( 45 | xmlrpc.client.Binary(open(arguments[0]).read())) 46 | # fix_print_with_import 47 | print("Plugin ID: %s" % plugin_id) 48 | # fix_print_with_import 49 | print("Version ID: %s" % version_id) 50 | except xmlrpc.client.ProtocolError as err: 51 | # fix_print_with_import 52 | print("A protocol error occurred") 53 | # fix_print_with_import 54 | print("URL: %s" % hide_password(err.url, 0)) 55 | # fix_print_with_import 56 | print("HTTP/HTTPS headers: %s" % err.headers) 57 | # fix_print_with_import 58 | print("Error code: %d" % err.errcode) 59 | # fix_print_with_import 60 | print("Error message: %s" % err.errmsg) 61 | except xmlrpc.client.Fault as err: 62 | # fix_print_with_import 63 | print("A fault occurred") 64 | # fix_print_with_import 65 | print("Fault code: %d" % err.faultCode) 66 | # fix_print_with_import 67 | print("Fault string: %s" % err.faultString) 68 | 69 | 70 | def hide_password(url, start=6): 71 | """Returns the http url with password part replaced with '*'. 72 | 73 | :param url: URL to upload the plugin to. 74 | :type url: str 75 | 76 | :param start: Position of start of password. 77 | :type start: int 78 | """ 79 | start_position = url.find(':', start) + 1 80 | end_position = url.find('@') 81 | return "%s%s%s" % ( 82 | url[:start_position], 83 | '*' * (end_position - start_position), 84 | url[end_position:]) 85 | 86 | 87 | if __name__ == "__main__": 88 | parser = OptionParser(usage="%prog [options] plugin.zip") 89 | parser.add_option( 90 | "-w", "--password", dest="password", 91 | help="Password for plugin site", metavar="******") 92 | parser.add_option( 93 | "-u", "--username", dest="username", 94 | help="Username of plugin site", metavar="user") 95 | parser.add_option( 96 | "-p", "--port", dest="port", 97 | help="Server port to connect to", metavar="80") 98 | parser.add_option( 99 | "-s", "--server", dest="server", 100 | help="Specify server name", metavar="plugins.qgis.org") 101 | options, args = parser.parse_args() 102 | if len(args) != 1: 103 | # fix_print_with_import 104 | print("Please specify zip file.\n") 105 | parser.print_help() 106 | sys.exit(1) 107 | if not options.server: 108 | options.server = SERVER 109 | if not options.port: 110 | options.port = PORT 111 | if not options.username: 112 | # interactive mode 113 | username = getpass.getuser() 114 | # fix_print_with_import 115 | print("Please enter user name [%s] :" % username, end=' ') 116 | res = input() 117 | if res != "": 118 | options.username = res 119 | else: 120 | options.username = username 121 | if not options.password: 122 | # interactive mode 123 | options.password = getpass.getpass() 124 | main(options, args) 125 | -------------------------------------------------------------------------------- /ClassAccuracyMain/pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | 3 | # Specify a configuration file. 4 | #rcfile= 5 | 6 | # Python code to execute, usually for sys.path manipulation such as 7 | # pygtk.require(). 8 | #init-hook= 9 | 10 | # Profiled execution. 11 | profile=no 12 | 13 | # Add files or directories to the blacklist. They should be base names, not 14 | # paths. 15 | ignore=CVS 16 | 17 | # Pickle collected data for later comparisons. 18 | persistent=yes 19 | 20 | # List of plugins (as comma separated values of python modules names) to load, 21 | # usually to register additional checkers. 22 | load-plugins= 23 | 24 | 25 | [MESSAGES CONTROL] 26 | 27 | # Enable the message, report, category or checker with the given id(s). You can 28 | # either give multiple identifier separated by comma (,) or put this option 29 | # multiple time. See also the "--disable" option for examples. 30 | #enable= 31 | 32 | # Disable the message, report, category or checker with the given id(s). You 33 | # can either give multiple identifiers separated by comma (,) or put this 34 | # option multiple times (only on the command line, not in the configuration 35 | # file where it should appear only once).You can also use "--disable=all" to 36 | # disable everything first and then reenable specific checks. For example, if 37 | # you want to run only the similarities checker, you can use "--disable=all 38 | # --enable=similarities". If you want to run only the classes checker, but have 39 | # no Warning level messages displayed, use"--disable=all --enable=classes 40 | # --disable=W" 41 | # see http://stackoverflow.com/questions/21487025/pylint-locally-defined-disables-still-give-warnings-how-to-suppress-them 42 | disable=locally-disabled,C0103 43 | 44 | 45 | [REPORTS] 46 | 47 | # Set the output format. Available formats are text, parseable, colorized, msvs 48 | # (visual studio) and html. You can also give a reporter class, eg 49 | # mypackage.mymodule.MyReporterClass. 50 | output-format=text 51 | 52 | # Put messages in a separate file for each module / package specified on the 53 | # command line instead of printing them on stdout. Reports (if any) will be 54 | # written in a file name "pylint_global.[txt|html]". 55 | files-output=no 56 | 57 | # Tells whether to display a full report or only the messages 58 | reports=yes 59 | 60 | # Python expression which should return a note less than 10 (10 is the highest 61 | # note). You have access to the variables errors warning, statement which 62 | # respectively contain the number of errors / warnings messages and the total 63 | # number of statements analyzed. This is used by the global evaluation report 64 | # (RP0004). 65 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 66 | 67 | # Add a comment according to your evaluation note. This is used by the global 68 | # evaluation report (RP0004). 69 | comment=no 70 | 71 | # Template used to display messages. This is a python new-style format string 72 | # used to format the message information. See doc for all details 73 | #msg-template= 74 | 75 | 76 | [BASIC] 77 | 78 | # Required attributes for module, separated by a comma 79 | required-attributes= 80 | 81 | # List of builtins function names that should not be used, separated by a comma 82 | bad-functions=map,filter,apply,input 83 | 84 | # Regular expression which should only match correct module names 85 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 86 | 87 | # Regular expression which should only match correct module level names 88 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 89 | 90 | # Regular expression which should only match correct class names 91 | class-rgx=[A-Z_][a-zA-Z0-9]+$ 92 | 93 | # Regular expression which should only match correct function names 94 | function-rgx=[a-z_][a-z0-9_]{2,30}$ 95 | 96 | # Regular expression which should only match correct method names 97 | method-rgx=[a-z_][a-z0-9_]{2,30}$ 98 | 99 | # Regular expression which should only match correct instance attribute names 100 | attr-rgx=[a-z_][a-z0-9_]{2,30}$ 101 | 102 | # Regular expression which should only match correct argument names 103 | argument-rgx=[a-z_][a-z0-9_]{2,30}$ 104 | 105 | # Regular expression which should only match correct variable names 106 | variable-rgx=[a-z_][a-z0-9_]{2,30}$ 107 | 108 | # Regular expression which should only match correct attribute names in class 109 | # bodies 110 | class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 111 | 112 | # Regular expression which should only match correct list comprehension / 113 | # generator expression variable names 114 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 115 | 116 | # Good variable names which should always be accepted, separated by a comma 117 | good-names=i,j,k,ex,Run,_ 118 | 119 | # Bad variable names which should always be refused, separated by a comma 120 | bad-names=foo,bar,baz,toto,tutu,tata 121 | 122 | # Regular expression which should only match function or class names that do 123 | # not require a docstring. 124 | no-docstring-rgx=__.*__ 125 | 126 | # Minimum line length for functions/classes that require docstrings, shorter 127 | # ones are exempt. 128 | docstring-min-length=-1 129 | 130 | 131 | [MISCELLANEOUS] 132 | 133 | # List of note tags to take in consideration, separated by a comma. 134 | notes=FIXME,XXX,TODO 135 | 136 | 137 | [TYPECHECK] 138 | 139 | # Tells whether missing members accessed in mixin class should be ignored. A 140 | # mixin class is detected if its name ends with "mixin" (case insensitive). 141 | ignore-mixin-members=yes 142 | 143 | # List of classes names for which member attributes should not be checked 144 | # (useful for classes with attributes dynamically set). 145 | ignored-classes=SQLObject 146 | 147 | # When zope mode is activated, add a predefined set of Zope acquired attributes 148 | # to generated-members. 149 | zope=no 150 | 151 | # List of members which are set dynamically and missed by pylint inference 152 | # system, and so shouldn't trigger E0201 when accessed. Python regular 153 | # expressions are accepted. 154 | generated-members=REQUEST,acl_users,aq_parent 155 | 156 | 157 | [VARIABLES] 158 | 159 | # Tells whether we should check for unused import in __init__ files. 160 | init-import=no 161 | 162 | # A regular expression matching the beginning of the name of dummy variables 163 | # (i.e. not used). 164 | dummy-variables-rgx=_$|dummy 165 | 166 | # List of additional names supposed to be defined in builtins. Remember that 167 | # you should avoid to define new builtins when possible. 168 | additional-builtins= 169 | 170 | 171 | [FORMAT] 172 | 173 | # Maximum number of characters on a single line. 174 | max-line-length=80 175 | 176 | # Regexp for a line that is allowed to be longer than the limit. 177 | ignore-long-lines=^\s*(# )??$ 178 | 179 | # Allow the body of an if to be on the same line as the test if there is no 180 | # else. 181 | single-line-if-stmt=no 182 | 183 | # List of optional constructs for which whitespace checking is disabled 184 | no-space-check=trailing-comma,dict-separator 185 | 186 | # Maximum number of lines in a module 187 | max-module-lines=1000 188 | 189 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 190 | # tab). 191 | indent-string=' ' 192 | 193 | 194 | [SIMILARITIES] 195 | 196 | # Minimum lines number of a similarity. 197 | min-similarity-lines=4 198 | 199 | # Ignore comments when computing similarities. 200 | ignore-comments=yes 201 | 202 | # Ignore docstrings when computing similarities. 203 | ignore-docstrings=yes 204 | 205 | # Ignore imports when computing similarities. 206 | ignore-imports=no 207 | 208 | 209 | [IMPORTS] 210 | 211 | # Deprecated modules which should not be used, separated by a comma 212 | deprecated-modules=regsub,TERMIOS,Bastion,rexec 213 | 214 | # Create a graph of every (i.e. internal and external) dependencies in the 215 | # given file (report RP0402 must not be disabled) 216 | import-graph= 217 | 218 | # Create a graph of external dependencies in the given file (report RP0402 must 219 | # not be disabled) 220 | ext-import-graph= 221 | 222 | # Create a graph of internal dependencies in the given file (report RP0402 must 223 | # not be disabled) 224 | int-import-graph= 225 | 226 | 227 | [DESIGN] 228 | 229 | # Maximum number of arguments for function / method 230 | max-args=5 231 | 232 | # Argument names that match this expression will be ignored. Default to name 233 | # with leading underscore 234 | ignored-argument-names=_.* 235 | 236 | # Maximum number of locals for function / method body 237 | max-locals=15 238 | 239 | # Maximum number of return / yield for function / method body 240 | max-returns=6 241 | 242 | # Maximum number of branch for function / method body 243 | max-branches=12 244 | 245 | # Maximum number of statements in function / method body 246 | max-statements=50 247 | 248 | # Maximum number of parents for a class (see R0901). 249 | max-parents=7 250 | 251 | # Maximum number of attributes for a class (see R0902). 252 | max-attributes=7 253 | 254 | # Minimum number of public methods for a class (see R0903). 255 | min-public-methods=2 256 | 257 | # Maximum number of public methods for a class (see R0904). 258 | max-public-methods=20 259 | 260 | 261 | [CLASSES] 262 | 263 | # List of interface methods to ignore, separated by a comma. This is used for 264 | # instance to not check methods defines in Zope's Interface base class. 265 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by 266 | 267 | # List of method names used to declare (i.e. assign) instance attributes. 268 | defining-attr-methods=__init__,__new__,setUp 269 | 270 | # List of valid names for the first argument in a class method. 271 | valid-classmethod-first-arg=cls 272 | 273 | # List of valid names for the first argument in a metaclass class method. 274 | valid-metaclass-classmethod-first-arg=mcs 275 | 276 | 277 | [EXCEPTIONS] 278 | 279 | # Exceptions that will emit a warning when being caught. Defaults to 280 | # "Exception" 281 | overgeneral-exceptions=Exception 282 | -------------------------------------------------------------------------------- /ClassAccuracyMain/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /ClassAccuracyMain/resources_rc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Resource object code 4 | # 5 | # Created by: The Resource Compiler for PyQt5 (Qt v5.6.2) 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore 10 | 11 | qt_resource_data = b"\ 12 | \x00\x00\x04\x96\ 13 | \x89\ 14 | \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ 15 | \x00\x00\x18\x00\x00\x00\x18\x08\x06\x00\x00\x00\xe0\x77\x3d\xf8\ 16 | \x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\ 17 | \x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\ 18 | \x9c\x18\x00\x00\x04\x3b\x49\x44\x41\x54\x48\x0d\xe5\x55\x5d\x6c\ 19 | \x14\x55\x14\xfe\xee\xcc\xec\xce\x76\xff\xba\xdd\xb6\xb6\x14\xb7\ 20 | \x45\x0a\x6d\x04\x2d\x28\x08\x88\x1a\xa4\x31\x31\x35\xc1\x18\x6c\ 21 | \x42\x52\x12\x62\x88\x31\xc2\x9b\xfa\x22\x9a\xf0\xa0\x3e\x18\x13\ 22 | \x7d\x31\x3e\x60\x4c\x7c\x41\x23\x6f\x86\x18\x62\x80\x20\xb1\x81\ 23 | \x92\xb6\x4a\x91\x56\xb1\x0d\x06\xb0\xed\xb2\x5b\xba\xdb\xd9\xdf\ 24 | \xe9\xcc\xce\x5c\xef\xbd\xd3\x99\x2e\xdd\x92\x18\x5f\xfd\x92\x3b\ 25 | \xf7\xfc\xdd\x73\xe6\xdc\x73\xce\x0c\xb9\xfc\xe3\xa5\xa9\x52\x64\ 26 | \xdb\x06\xb8\xa0\x14\x72\x45\x83\xa5\xd4\x03\x84\xb8\xd2\x7f\xb5\ 27 | \xe7\x17\x35\x44\x54\x76\xae\x0a\x4a\x2c\x73\xa6\x55\x31\xee\x66\ 28 | \x4c\x35\x11\xe7\x8e\x83\x85\x31\x28\x95\x0c\x2c\x39\x8c\x72\xa8\ 29 | \x07\xc5\xc8\x36\x58\xbe\x78\xd5\x91\xd5\xc9\x13\xc3\x1f\xe3\xc2\ 30 | \xcd\xd3\xd8\x95\xe8\xc5\x5b\xcf\x7e\xe4\x19\x29\xa0\x76\x38\x9c\ 31 | \x1f\x05\xf8\xaa\x02\xad\xe4\x10\xce\x5d\x46\x28\x37\x04\xad\xf1\ 32 | \x25\x94\x22\xdb\xab\xb4\xb5\xe4\xc8\xf4\xcf\x42\x38\x3a\x33\x08\ 33 | \xca\x6e\x81\x2c\x65\x2f\xad\x34\xcd\x99\x06\x06\xae\x0e\xa2\x6f\ 34 | \xf8\x02\x86\x17\xee\x81\x80\x22\x9a\x39\x07\x50\xcb\x33\xe5\x0e\ 35 | \x0a\x46\xce\xe3\x39\x31\xb0\xe5\x08\x12\xf5\xeb\x71\x70\xeb\x51\ 36 | \xcf\x39\x97\x2b\xfc\x51\x8d\x89\x82\x86\xbf\xf5\x92\x10\x5d\x9c\ 37 | \x4f\x61\x47\xac\x09\x12\x35\x9c\xba\xb0\xab\xb2\x6d\x0b\xc7\xcf\ 38 | \xbf\x89\xa9\xf9\x09\x1c\xe8\x79\x03\xfb\x37\xbf\x26\x6c\x7b\x3b\ 39 | \xf7\x81\xaf\x95\xa8\x09\xf0\x44\x34\x8e\xa7\xea\x1b\x71\x77\xb1\ 40 | \x8c\x7d\x2d\x0f\x7b\xf6\xc4\x36\x04\xbd\xa0\x67\x84\x73\xce\x8c\ 41 | \x4e\x0f\x7a\x01\x38\x2f\xfb\xfe\x84\xe2\xbf\xce\x32\xc8\xb3\x6b\ 42 | \x0a\xc1\x32\xbb\x6a\x33\x08\xc8\x32\x3e\xdb\x54\x7b\xdf\xea\xe2\ 43 | \x2d\x54\xd4\x56\xc4\x83\xcd\x78\xf9\xd1\x83\x18\x4b\x5e\x41\xff\ 44 | \x63\x87\xb9\x5f\x01\x45\x1d\x82\x1a\x3c\xeb\xb2\x8e\xcc\xff\x07\ 45 | \xc8\xf8\xc9\x77\xe9\x89\x3b\x93\xec\x8d\x75\x1c\xed\xe8\x42\x8b\ 46 | \x5a\x77\x9f\x91\xc7\x10\x89\x6a\xb1\x17\x08\x6b\x69\x50\xc9\xef\ 47 | \x89\x1d\xc2\x46\x30\xf6\x09\x7b\xf3\xc5\x15\x72\x56\x83\x51\x6d\ 48 | \x1e\xdf\xce\xde\x12\x8a\xa8\xe2\xc3\x3b\xeb\x37\xd5\x18\x09\x01\ 49 | \xb5\x49\x7d\xf6\x2c\x9a\xc6\x4f\x81\x68\x01\xa4\x9f\x79\x15\xe5\ 50 | \x48\x0f\x0b\xa6\x82\x48\x9a\x70\xae\x95\x0d\x7c\x78\xe6\x57\x14\ 51 | \x8d\x0a\xde\x7b\x71\x2b\x12\xf1\x30\x94\xf6\xba\x10\xea\x24\x19\ 52 | \x65\x56\xbc\xee\x50\x54\xf8\x2a\x54\x4c\x1c\x9f\xbc\x86\x1c\xdf\ 53 | \x37\xf6\x80\xdb\x70\xf8\x52\x59\x74\x1e\xfb\x12\xc4\xb2\x11\xed\ 54 | \xff\x05\xa9\xfe\x3e\xa4\x12\x6f\x0b\x1d\x7f\x8c\xdc\x9e\xc3\x8d\ 55 | \x94\x26\xf8\x9f\x26\x67\x71\x68\x17\xab\x41\x2b\xbb\x92\x53\x4f\ 56 | \x3e\x07\xcd\x34\xb1\x2e\x18\x16\xca\xa1\xec\x1c\x46\x58\x66\x1c\ 57 | \x3f\xa4\xa7\xd9\xd5\x75\x0b\x5a\x2e\x94\x85\x73\xce\x28\xd9\x02\ 58 | \x6c\x29\x20\xe4\xa0\xb2\xd8\xb7\xac\x8d\xa3\x39\x1c\x40\xd9\xb4\ 59 | \xb0\xf3\x91\x87\x84\x4c\x74\x51\x83\x4f\x05\x5f\x2e\x7a\xa2\x0d\ 60 | \x68\x64\x7c\xd1\xaa\x60\x77\x43\xb3\x2b\x86\xde\xd9\x86\xe4\xeb\ 61 | \x7d\xf0\x27\x33\x48\xee\x7f\x05\x99\x96\x01\xa1\x23\x92\xd3\xd6\ 62 | \xcd\x91\x3a\x7c\x7d\x68\x0f\x6c\x36\x27\xd2\xd2\xa0\x91\xdf\xbf\ 63 | \x39\x46\x3d\x0f\x55\x84\xc5\x8c\xf8\xf2\x4b\xcb\xb3\x68\xfb\x00\ 64 | \x9b\x35\x5e\x31\xdc\x8b\x62\x74\x27\xfb\x56\x39\x3a\x35\x78\xda\ 65 | \x54\xd4\xab\x4c\x5b\x8b\x9a\x39\x70\x4d\x64\xf6\x06\x7c\x71\x98\ 66 | \x51\x94\xf4\x04\x2d\xd9\x7e\xd2\x04\x54\x60\x57\xc6\xe0\x33\x75\ 67 | \x36\xdd\xea\xac\x12\x18\x2b\x48\xd2\x5c\x97\x7b\x6e\xe5\xfe\xc0\ 68 | \x00\xdc\x90\xa7\xa6\xb7\xd3\x45\xa3\x91\x04\xd9\xeb\xb2\xe5\x40\ 69 | \x52\xd2\xf0\xb3\xc5\xd0\xc6\x1f\x5f\x5d\xba\x81\x89\x64\x16\x87\ 70 | \x9f\xee\xc6\xe3\xac\x0e\xd5\xf0\xf2\x3f\x77\x2f\x89\x93\x33\x7f\ 71 | \xa1\xc4\xee\xdd\x85\xc1\xea\xc4\x9c\x2f\x17\xc7\x55\x54\xed\x33\ 72 | \x0b\x45\x7c\x7f\xed\x36\xa6\xd2\x39\x7c\x37\x7a\xb3\x4a\xe3\x90\ 73 | \x22\x83\xf1\xfc\x02\x3e\x98\xfa\x4d\x48\xf2\xac\x35\x8f\xb0\xae\ 74 | \xb1\xd9\x2c\xe9\x6d\xfc\x0b\x47\x9c\x16\xa9\x39\xea\x08\x78\xd7\ 75 | \xb4\x37\x84\x70\x27\x5b\xc4\xf6\x8e\xe5\x86\x70\xcd\x45\x80\x00\ 76 | \x9b\x03\x17\x75\x32\xfb\x82\x33\xa6\xb4\x8e\xf2\xe9\xf1\xfe\x1e\ 77 | \xfc\x0b\x7a\x71\x2a\x29\xcc\x9e\xdf\xb8\x86\xa9\x9c\xfa\xf8\x15\ 78 | \x19\x9f\x1f\xd8\x8d\xbc\x6e\x22\x16\xac\x4d\x56\x04\xd8\x10\x8a\ 79 | \xe0\x8b\xcd\x3b\x90\x36\x74\xec\x6d\x6c\x45\xb9\x9d\xa6\xac\x10\ 80 | \x69\x71\x83\xf2\x9d\x3b\xff\xf4\xfc\x75\x4f\xb4\xb7\x4b\x5c\xbf\ 81 | \xe0\x65\xd6\x69\xab\x39\xe7\x4a\xaf\xc8\xbc\xf7\x29\xab\x48\xb9\ 82 | \x83\xa6\xcd\xd8\xfd\xce\x3d\xaf\xff\x81\x10\x01\x28\xcb\xd6\x68\ 83 | \xa2\xd3\xfa\x1a\x12\x62\xbd\xe9\x8c\xe0\x0a\x67\xfc\x5a\x5c\x54\ 84 | \xd3\xae\xec\x41\xbb\x62\x46\xec\xf7\xf5\xb5\x08\x55\x02\xc4\x14\ 85 | \x8d\xb9\xea\xd8\x39\xc7\xf7\x2c\x05\xe1\x26\xbc\x26\xff\x0f\xfc\ 86 | \x03\x92\x2b\x80\x83\x25\x79\xc9\x52\x00\x00\x00\x00\x49\x45\x4e\ 87 | \x44\xae\x42\x60\x82\ 88 | " 89 | 90 | qt_resource_name = b"\ 91 | \x00\x07\ 92 | \x07\x3b\xe0\xb3\ 93 | \x00\x70\ 94 | \x00\x6c\x00\x75\x00\x67\x00\x69\x00\x6e\x00\x73\ 95 | \x00\x11\ 96 | \x08\x79\xcc\x7e\ 97 | \x00\x43\ 98 | \x00\x6c\x00\x61\x00\x73\x00\x73\x00\x41\x00\x63\x00\x63\x00\x75\x00\x72\x00\x61\x00\x63\x00\x79\x00\x4d\x00\x61\x00\x69\x00\x6e\ 99 | \ 100 | \x00\x08\ 101 | \x0a\x61\x5a\xa7\ 102 | \x00\x69\ 103 | \x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\ 104 | " 105 | 106 | qt_resource_struct = b"\ 107 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 108 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 109 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ 110 | \x00\x00\x00\x3c\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 111 | " 112 | 113 | def qInitResources(): 114 | QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) 115 | 116 | def qCleanupResources(): 117 | QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) 118 | 119 | qInitResources() 120 | -------------------------------------------------------------------------------- /ClassAccuracyMain/rsgisclassacc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | ClassAccuracyMain 5 | A QGIS plugin 6 | Manually review the accuracy of a classification 7 | ------------------- 8 | begin : 2015-08-15 9 | git sha : $Format:%H$ 10 | copyright : (C) 2015 by Pete Bunting 11 | email : pfb@aber.ac.uk 12 | ***************************************************************************/ 13 | 14 | /*************************************************************************** 15 | * * 16 | * This program is free software; you can redistribute it and/or modify * 17 | * it under the terms of the GNU General Public License as published by * 18 | * the Free Software Foundation; either version 2 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | ***************************************************************************/ 22 | """ 23 | """from PyQt4.QtCore import QSettings, QTranslator, qVersion, QCoreApplication 24 | from PyQt4.QtGui import QAction, QIcon""" 25 | from PyQt5.QtCore import QSettings, QTranslator, QVersionNumber, QCoreApplication, Qt, QObject, pyqtSignal 26 | from PyQt5.QtGui import QIcon 27 | from PyQt5.QtWidgets import QAction, QDialog, QFormLayout 28 | # Initialize Qt resources from file resources.py 29 | from . import resources_rc 30 | # Import the code for the dialog 31 | from .rsgisclassacc_dialog import ClassAccuracyMainDialog 32 | import os.path 33 | 34 | 35 | class ClassAccuracyMain: 36 | """QGIS Plugin Implementation.""" 37 | 38 | def __init__(self, iface): 39 | """Constructor. 40 | 41 | :param iface: An interface instance that will be passed to this class 42 | which provides the hook by which you can manipulate the QGIS 43 | application at run time. 44 | :type iface: QgsInterface 45 | """ 46 | # Save reference to the QGIS interface 47 | self.iface = iface 48 | # initialize plugin directory 49 | self.plugin_dir = os.path.dirname(__file__) 50 | # initialize locale 51 | locale = QSettings().value('locale/userLocale')[0:2] 52 | locale_path = os.path.join( 53 | self.plugin_dir, 54 | 'i18n', 55 | 'ClassAccuracyMain_{}.qm'.format(locale)) 56 | 57 | if os.path.exists(locale_path): 58 | self.translator = QTranslator() 59 | self.translator.load(locale_path) 60 | 61 | if qVersion() > '4.3.3': 62 | QCoreApplication.installTranslator(self.translator) 63 | 64 | # Create the dialog (after translation) and keep reference 65 | self.dlg = ClassAccuracyMainDialog() 66 | 67 | # Declare instance attributes 68 | self.actions = [] 69 | self.menu = self.tr(u'&ClassAccuracy') 70 | # Setup toolbar - if needed. 71 | self.toolbar = self.iface.addToolBar(u'ClassAccuracyMain') 72 | self.toolbar.setObjectName(u'ClassAccuracyMain') 73 | 74 | # noinspection PyMethodMayBeStatic 75 | def tr(self, message): 76 | """Get the translation for a string using Qt translation API. 77 | 78 | We implement this ourselves since we do not inherit QObject. 79 | 80 | :param message: String for translation. 81 | :type message: str, QString 82 | 83 | :returns: Translated version of message. 84 | :rtype: QString 85 | """ 86 | # noinspection PyTypeChecker,PyArgumentList,PyCallByClass 87 | return QCoreApplication.translate('ClassAccuracyMain', message) 88 | 89 | 90 | def add_action( 91 | self, 92 | icon_path, 93 | text, 94 | callback, 95 | enabled_flag=True, 96 | add_to_menu=True, 97 | add_to_toolbar=True, 98 | status_tip=None, 99 | whats_this=None, 100 | parent=None): 101 | """Add a toolbar icon to the toolbar. 102 | 103 | :param icon_path: Path to the icon for this action. Can be a resource 104 | path (e.g. ':/plugins/foo/bar.png') or a normal file system path. 105 | :type icon_path: str 106 | 107 | :param text: Text that should be shown in menu items for this action. 108 | :type text: str 109 | 110 | :param callback: Function to be called when the action is triggered. 111 | :type callback: function 112 | 113 | :param enabled_flag: A flag indicating if the action should be enabled 114 | by default. Defaults to True. 115 | :type enabled_flag: bool 116 | 117 | :param add_to_menu: Flag indicating whether the action should also 118 | be added to the menu. Defaults to True. 119 | :type add_to_menu: bool 120 | 121 | :param add_to_toolbar: Flag indicating whether the action should also 122 | be added to the toolbar. Defaults to True. 123 | :type add_to_toolbar: bool 124 | 125 | :param status_tip: Optional text to show in a popup when mouse pointer 126 | hovers over the action. 127 | :type status_tip: str 128 | 129 | :param parent: Parent widget for the new action. Defaults None. 130 | :type parent: QWidget 131 | 132 | :param whats_this: Optional text to show in the status bar when the 133 | mouse pointer hovers over the action. 134 | 135 | :returns: The action that was created. Note that the action is also 136 | added to self.actions list. 137 | :rtype: QAction 138 | """ 139 | 140 | icon = QIcon(icon_path) 141 | action = QAction(icon, text, parent) 142 | action.triggered.connect(callback) 143 | action.setEnabled(enabled_flag) 144 | 145 | if status_tip is not None: 146 | action.setStatusTip(status_tip) 147 | 148 | if whats_this is not None: 149 | action.setWhatsThis(whats_this) 150 | 151 | if add_to_toolbar: 152 | self.toolbar.addAction(action) 153 | 154 | if add_to_menu: 155 | self.iface.addPluginToMenu( 156 | self.menu, 157 | action) 158 | 159 | self.actions.append(action) 160 | 161 | return action 162 | 163 | def initGui(self): 164 | """Create the menu entries and toolbar icons inside the QGIS GUI.""" 165 | 166 | icon_path = ':/plugins/ClassAccuracyMain/icon.png' 167 | self.add_action( 168 | icon_path, 169 | text=self.tr(u'Class Accuracy'), 170 | callback=self.run, 171 | parent=self.iface.mainWindow()) 172 | 173 | 174 | def unload(self): 175 | """Removes the plugin menu item and icon from QGIS GUI.""" 176 | for action in self.actions: 177 | self.iface.removePluginMenu( 178 | self.tr(u'&ClassAccuracy'), 179 | action) 180 | self.iface.removeToolBarIcon(action) 181 | # remove the toolbar 182 | del self.toolbar 183 | 184 | 185 | def run(self): 186 | """Run method that performs all the real work""" 187 | # show the dialog 188 | self.dlg.populateLayers() 189 | self.dlg.show() 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /ClassAccuracyMain/rsgisclassacc_dialog.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | ClassAccuracyMainDialog 5 | A QGIS plugin 6 | Manually review the accuracy of a classification 7 | ------------------- 8 | begin : 2015-08-15 9 | git sha : $Format:%H$ 10 | copyright : (C) 2015 by Pete Bunting 11 | email : pfb@aber.ac.uk 12 | ***************************************************************************/ 13 | 14 | /*************************************************************************** 15 | * * 16 | * This program is free software; you can redistribute it and/or modify * 17 | * it under the terms of the GNU General Public License as published by * 18 | * the Free Software Foundation; either version 2 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | ***************************************************************************/ 22 | """ 23 | 24 | from builtins import str 25 | from builtins import range 26 | import os 27 | 28 | from qgis.PyQt import QtCore, QtGui 29 | from PyQt5 import QtWidgets as QW 30 | import qgis.utils 31 | import numpy 32 | import csv 33 | from qgis.core import QgsVectorLayerUtils 34 | 35 | MESSAGE_TIMEOUT = 20000 36 | FEAT_BUFFER = 0.02 37 | 38 | 39 | class ClassNamesQComboBox(QW.QComboBox): 40 | 41 | nextFeatSignal = QtCore.pyqtSignal() 42 | 43 | def __init__(self, parent=None): 44 | super(ClassNamesQComboBox, self).__init__(parent) 45 | self.setEditable(False) 46 | 47 | def keyPressEvent(self, event): 48 | if (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_1): 49 | if self.count() > 0: 50 | self.setCurrentIndex(0) 51 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_2): 52 | if self.count() > 1: 53 | self.setCurrentIndex(1) 54 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_3): 55 | if self.count() > 2: 56 | self.setCurrentIndex(2) 57 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_4): 58 | if self.count() > 3: 59 | self.setCurrentIndex(3) 60 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_5): 61 | if self.count() > 4: 62 | self.setCurrentIndex(4) 63 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_6): 64 | if self.count() > 5: 65 | self.setCurrentIndex(5) 66 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_7): 67 | if self.count() > 6: 68 | self.setCurrentIndex(6) 69 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_8): 70 | if self.count() > 7: 71 | self.setCurrentIndex(7) 72 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_9): 73 | if self.count() > 8: 74 | self.setCurrentIndex(8) 75 | elif (event.type() == QtCore.QEvent.KeyPress) and (event.key() == QtCore.Qt.Key_0): 76 | if self.count() > 9: 77 | self.setCurrentIndex(9) 78 | elif (event.type() == QtCore.QEvent.KeyPress) and ((event.key() == QtCore.Qt.Key_Return) or (event.key() == QtCore.Qt.Key_Enter)): 79 | self.nextFeatSignal.emit() 80 | 81 | 82 | class ClassAccuracyMainDialog(QW.QDialog): 83 | 84 | def __init__(self, parent=None): 85 | """Constructor.""" 86 | QW.QWidget.__init__(self, parent) 87 | # Set window size. 88 | self.resize(320, 240) 89 | 90 | # Set window title 91 | self.setWindowTitle("Accuracy Assessment Tool") 92 | 93 | # Create mainLayout 94 | self.mainLayout = QW.QVBoxLayout() 95 | 96 | self.guiLabelStep1 = QW.QLabel() 97 | self.guiLabelStep1.setText("1. Select a Vector Layer:") 98 | self.mainLayout.addWidget(self.guiLabelStep1) 99 | 100 | self.availLayersCombo = QW.QComboBox() 101 | self.availLayersCombo.currentIndexChanged['QString'].connect(self.populateLayerInfo) 102 | self.mainLayout.addWidget(self.availLayersCombo) 103 | 104 | self.guiLabelStep2 = QW.QLabel() 105 | self.guiLabelStep2.setText("2. Select Columns:") 106 | self.mainLayout.addWidget(self.guiLabelStep2) 107 | 108 | self.classNameComboLabel = QW.QLabel() 109 | self.classNameComboLabel.setText("Classified Column:") 110 | self.classNameCombo = QW.QComboBox() 111 | self.classNameLayout = QW.QHBoxLayout() 112 | self.classNameLayout.addWidget(self.classNameComboLabel) 113 | self.classNameLayout.addWidget(self.classNameCombo) 114 | self.mainLayout.addLayout(self.classNameLayout) 115 | 116 | self.classNameOutComboLabel = QW.QLabel() 117 | self.classNameOutComboLabel.setText("Output Column:") 118 | self.classNameOutCombo = QW.QComboBox() 119 | self.classNameOutLayout = QW.QHBoxLayout() 120 | self.classNameOutLayout.addWidget(self.classNameOutComboLabel) 121 | self.classNameOutLayout.addWidget(self.classNameOutCombo) 122 | self.mainLayout.addLayout(self.classNameOutLayout) 123 | 124 | self.featProcessedComboLabel = QW.QLabel() 125 | self.featProcessedComboLabel.setText("Processed Column:") 126 | self.featProcessedCombo = QW.QComboBox() 127 | self.featProcessedLayout = QW.QHBoxLayout() 128 | self.featProcessedLayout.addWidget(self.featProcessedComboLabel) 129 | self.featProcessedLayout.addWidget(self.featProcessedCombo) 130 | self.mainLayout.addLayout(self.featProcessedLayout) 131 | 132 | self.visitProcessedCheckBox = QW.QCheckBox("Visit Processed Points") 133 | self.visitProcessedCheckBox.setCheckState(QtCore.Qt.Unchecked) 134 | self.visitProcessedLayout = QW.QHBoxLayout() 135 | self.visitProcessedLayout.addWidget(self.visitProcessedCheckBox) 136 | self.mainLayout.addLayout(self.visitProcessedLayout) 137 | 138 | self.guiLabelStep3 = QW.QLabel() 139 | self.guiLabelStep3.setText("3. Press Start when ready:") 140 | self.mainLayout.addWidget(self.guiLabelStep3) 141 | 142 | # Start and Finish buttons 143 | self.startButton = QW.QPushButton(self) 144 | self.startButton.setText("Start") 145 | self.startButton.setDefault(True) 146 | #self.connect(self.startButton, QtCore.SIGNAL("clicked()"), self.startProcessing) 147 | self.startButton.clicked.connect(self.startProcessing) 148 | 149 | self.finishButton = QW.QPushButton(self) 150 | self.finishButton.setText("Finish") 151 | #self.connect(self.finishButton, QtCore.SIGNAL("clicked()"), self.finishProcessing) 152 | #self.connect(self.finishButton, QtCore.SIGNAL("clicked()"), self.reject) 153 | self.finishButton.clicked.connect(self.finishProcessing) 154 | self.finishButton.clicked.connect(self.reject) 155 | 156 | self.mainButtonLayout = QW.QHBoxLayout() 157 | self.mainButtonLayout.addWidget(self.finishButton) 158 | self.mainButtonLayout.addWidget(self.startButton) 159 | self.mainLayout.addLayout(self.mainButtonLayout) 160 | 161 | self.guiLabelStep4 = QW.QLabel() 162 | self.guiLabelStep4.setText("4. Go through the features (Press Return for Next):") 163 | self.mainLayout.addWidget(self.guiLabelStep4) 164 | 165 | # next and prev buttons 166 | self.nextButton = QW.QPushButton(self) 167 | self.nextButton.setText("Next") 168 | #self.connect(self.nextButton, QtCore.SIGNAL("clicked()"), self.nextFeat) 169 | self.nextButton.clicked.connect(self.nextFeat) 170 | self.nextButton.setDisabled(True) 171 | 172 | self.prevButton = QW.QPushButton(self) 173 | self.prevButton.setText("Prev") 174 | #self.connect(self.prevButton, QtCore.SIGNAL("clicked()"), self.prevFeat) 175 | self.prevButton.clicked.connect(self.prevFeat) 176 | self.prevButton.setDisabled(True) 177 | 178 | self.ctrlButtonLayout = QW.QHBoxLayout() 179 | self.ctrlButtonLayout.addWidget(self.prevButton) 180 | self.ctrlButtonLayout.addWidget(self.nextButton) 181 | self.mainLayout.addLayout(self.ctrlButtonLayout) 182 | 183 | self.assignButton = QW.QPushButton(self) 184 | self.assignButton.setText("Assign") 185 | #self.connect(self.assignButton, QtCore.SIGNAL("clicked()"), self.assignFeats) 186 | self.assignButton.clicked.connect(self.assignFeats) 187 | self.assignButton.setDisabled(True) 188 | self.assignButtonLayout = QW.QHBoxLayout() 189 | self.assignButtonLayout.addWidget(self.assignButton) 190 | self.mainLayout.addLayout(self.assignButtonLayout) 191 | 192 | self.guiLabelStep4b = QW.QLabel() 193 | self.guiLabelStep4b.setText("4. Or go direct to a feature (index starts at 1):") 194 | self.mainLayout.addWidget(self.guiLabelStep4b) 195 | self.goToLabel = QW.QLabel() 196 | self.goToLabel.setText("Go to Feature (ID):") 197 | self.goToTextField = QW.QLineEdit() 198 | self.goToTextField.setDisabled(True) 199 | self.goToButton = QW.QPushButton(self) 200 | self.goToButton.setText("Go To") 201 | #self.connect(self.goToButton, QtCore.SIGNAL("clicked()"), self.goToFeat) 202 | self.goToButton.clicked.connect(self.goToFeat) 203 | self.goToButton.setDisabled(True) 204 | self.goToLayout = QW.QHBoxLayout() 205 | self.goToLayout.addWidget(self.goToLabel) 206 | self.goToLayout.addWidget(self.goToTextField) 207 | self.goToLayout.addWidget(self.goToButton) 208 | self.mainLayout.addLayout(self.goToLayout) 209 | 210 | self.guiLabelStep5 = QW.QLabel() 211 | self.guiLabelStep5.setText("5. Change class if incorrect:") 212 | self.mainLayout.addWidget(self.guiLabelStep5) 213 | 214 | # classified and correct combo options 215 | self.fidLabel = QW.QLabel() 216 | self.fidLabel.setDisabled(True) 217 | self.classifiedLabel = QW.QLabel() 218 | self.classifiedLabel.setDisabled(True) 219 | self.classesCombo = ClassNamesQComboBox() 220 | self.classesCombo.setDisabled(True) 221 | self.classesCombo.nextFeatSignal.connect(self.nextFeat) 222 | 223 | self.classesInfoLayout = QW.QHBoxLayout() 224 | self.classesInfoLayout.addWidget(self.fidLabel) 225 | self.classesInfoLayout.addWidget(self.classifiedLabel) 226 | self.classesInfoLayout.addWidget(self.classesCombo) 227 | self.mainLayout.addLayout(self.classesInfoLayout) 228 | 229 | self.guiLabelStep6 = QW.QLabel() 230 | self.guiLabelStep6.setText("6. Add extra classes to the list:") 231 | self.mainLayout.addWidget(self.guiLabelStep6) 232 | 233 | self.addClassLabel = QW.QLabel() 234 | self.addClassLabel.setText("Class Name:") 235 | self.addClassField = QW.QLineEdit() 236 | self.addClassField.setDisabled(True) 237 | self.addClassButton = QW.QPushButton(self) 238 | self.addClassButton.setText("Add") 239 | #self.connect(self.addClassButton, QtCore.SIGNAL("clicked()"), self.addClassName) 240 | self.addClassButton.clicked.connect(self.addClassName) 241 | self.addClassButton.setDisabled(True) 242 | self.addClassLayout = QW.QHBoxLayout() 243 | self.addClassLayout.addWidget(self.addClassLabel) 244 | self.addClassLayout.addWidget(self.addClassField) 245 | self.addClassLayout.addWidget(self.addClassButton) 246 | self.mainLayout.addLayout(self.addClassLayout) 247 | 248 | self.guiLabelStep7 = QW.QLabel() 249 | self.guiLabelStep7.setText("7. Change scale:") 250 | self.mainLayout.addWidget(self.guiLabelStep7) 251 | 252 | self.cScaleBuffer = FEAT_BUFFER 253 | 254 | self.scaleOptionsTextLine = QW.QLineEdit() 255 | self.scaleOptionsTextLine.setText(str(self.cScaleBuffer)) 256 | self.scaleOptionsTextLine.setDisabled(True) 257 | self.changeScaleButton = QW.QPushButton(self) 258 | self.changeScaleButton.setText("Update") 259 | #self.connect(self.changeScaleButton, QtCore.SIGNAL("clicked()"), self.updateScale) 260 | self.changeScaleButton.clicked.connect(self.updateScale) 261 | self.changeScaleButton.setDisabled(True) 262 | self.scaleLayout = QW.QHBoxLayout() 263 | self.scaleLayout.addWidget(self.scaleOptionsTextLine) 264 | self.scaleLayout.addWidget(self.changeScaleButton) 265 | self.mainLayout.addLayout(self.scaleLayout) 266 | 267 | self.guiLabelStep8 = QW.QLabel() 268 | self.guiLabelStep8.setText("8. Produce Error Matrix:") 269 | self.mainLayout.addWidget(self.guiLabelStep8) 270 | 271 | self.calcErrorMatrixButton = QW.QPushButton(self) 272 | self.calcErrorMatrixButton.setText("Calc Error Matrix") 273 | #self.connect(self.calcErrorMatrixButton, QtCore.SIGNAL("clicked()"), self.calcErrMatrix) 274 | self.calcErrorMatrixButton.clicked.connect(self.calcErrMatrix) 275 | self.calcErrorMatrixButton.setDisabled(True) 276 | self.mainLayout.addWidget(self.calcErrorMatrixButton) 277 | 278 | self.setLayout(self.mainLayout) 279 | 280 | self.started = False 281 | self.justAssigned = False 282 | 283 | 284 | def populateLayers(self): 285 | """ Initialise layers list """ 286 | self.availLayersCombo.clear() 287 | self.classNameCombo.clear() 288 | self.classNameOutCombo.clear() 289 | self.featProcessedCombo.clear() 290 | 291 | qgisIface = qgis.utils.iface 292 | mCanvas = qgisIface.mapCanvas() 293 | 294 | allLayers = mCanvas.layers() 295 | first = True 296 | for layer in allLayers: 297 | self.availLayersCombo.addItem(str(layer.name())) 298 | 299 | def populateLayerInfo(self, selectedName): 300 | """ Populate the layer information from the selected layer """ 301 | self.classNameCombo.clear() 302 | self.classNameOutCombo.clear() 303 | self.featProcessedCombo.clear() 304 | 305 | qgisIface = qgis.utils.iface 306 | mCanvas = qgisIface.mapCanvas() 307 | 308 | allLayers = mCanvas.layers() 309 | found = False 310 | fieldNames = list() 311 | for layer in allLayers: 312 | if layer.name() == selectedName: 313 | layerFields = layer.fields() #pendingFields 314 | numFields = layerFields.size() 315 | for i in range(numFields): 316 | field = layerFields.field(i) 317 | if field not in fieldNames: 318 | self.classNameCombo.addItem(str(field.name())) 319 | self.classNameOutCombo.addItem(str(field.name())) 320 | self.featProcessedCombo.addItem(str(field.name())) 321 | fieldNames.append(field) 322 | found = True 323 | break 324 | 325 | def startProcessing(self): 326 | """ Starting Processing """ 327 | if not self.started: 328 | 329 | qgisIface = qgis.utils.iface 330 | 331 | mCanvas = qgisIface.mapCanvas() 332 | mCanvas.setSelectionColor( QtGui.QColor("yellow") ) 333 | 334 | selectedIdx = self.availLayersCombo.currentIndex() 335 | selectedName = self.availLayersCombo.itemText(selectedIdx) 336 | 337 | self.selectedClassFieldIdx = self.classNameCombo.currentIndex() 338 | self.selectedClassFieldName = self.classNameCombo.itemText(self.selectedClassFieldIdx) 339 | 340 | self.selectedClassOutFieldIdx = self.classNameOutCombo.currentIndex() 341 | self.selectedClassOutFieldName = self.classNameOutCombo.itemText(self.selectedClassOutFieldIdx) 342 | 343 | self.selectedFeatProcessedFieldIdx = self.featProcessedCombo.currentIndex() 344 | self.selectedFeatProcessedFieldName = self.featProcessedCombo.itemText(self.selectedFeatProcessedFieldIdx) 345 | 346 | allLayers = mCanvas.layers() 347 | found = False 348 | for layer in allLayers: 349 | if layer.name() == selectedName: 350 | self.featLayer = layer 351 | break 352 | 353 | self.selectedClassFieldIdx = self.featLayer.fields().indexFromName(self.selectedClassFieldName) 354 | self.selectedClassFieldOutIdx = self.featLayer.fields().indexFromName(self.selectedClassOutFieldName) 355 | self.selectedFeatProcessedFieldIdx = self.featLayer.fields().indexFromName(self.selectedFeatProcessedFieldName) 356 | 357 | self.onlyGoToUnProcessedFeats = True 358 | if self.visitProcessedCheckBox.checkState() == QtCore.Qt.Checked: 359 | self.onlyGoToUnProcessedFeats = False 360 | 361 | self.classNamesTmpList = QgsVectorLayerUtils.getValues(self.featLayer, self.selectedClassFieldName) 362 | self.classNamesList = list(set(self.classNamesTmpList[0])) 363 | 364 | classOutNamesTmpList = QgsVectorLayerUtils.getValues(self.featLayer, self.selectedClassOutFieldName) 365 | classOutNamesList = list(set(classOutNamesTmpList[0])) 366 | 367 | for classOutName in classOutNamesList: 368 | if (not classOutName in self.classNamesList) and (not classOutName == 'NULL') and (not classOutName == None): 369 | self.classNamesList.append(str(classOutName)) 370 | 371 | for className in self.classNamesList: 372 | self.classesCombo.addItem(str(className)) 373 | 374 | self.numFeats = self.featLayer.featureCount() 375 | self.cFeatN = 0 376 | 377 | self.featLayer.selectByIds([]) 378 | 379 | self.featIter = self.featLayer.getFeatures() 380 | self.cFeat = next(self.featIter) 381 | if self.cFeatN < self.numFeats: 382 | 383 | availFeats = True 384 | if self.onlyGoToUnProcessedFeats: 385 | foundUnProcessedFeat = False 386 | while not foundUnProcessedFeat: 387 | if int(self.cFeat[self.selectedFeatProcessedFieldIdx]) == 0: 388 | foundUnProcessedFeat = True 389 | else: 390 | self.cFeatN = self.cFeatN + 1 391 | if self.cFeatN < self.numFeats: 392 | self.cFeat = next(self.featIter) 393 | else: 394 | availFeats = False 395 | break 396 | 397 | if availFeats: 398 | self.featLayer.startEditing() 399 | self.featLayer.selectByIds([self.cFeat.id()]) 400 | 401 | cClassName = str(self.cFeat[self.selectedClassFieldIdx]) 402 | self.classifiedLabel.setText(cClassName) 403 | 404 | outClassName = str(self.cFeat[self.selectedClassOutFieldIdx]) 405 | if (outClassName == None) or (outClassName.strip() == "") or (not (outClassName.strip() in self.classNamesList)): 406 | self.classesCombo.setCurrentIndex(self.classNamesList.index(cClassName)) 407 | else: 408 | self.classesCombo.setCurrentIndex(self.classNamesList.index(outClassName)) 409 | 410 | self.fidLabel.setText(str(self.cFeat.id()+1) + " of " + str(self.numFeats)) 411 | 412 | box = self.featLayer.boundingBoxOfSelected() 413 | box = box.buffered(self.cScaleBuffer) 414 | mCanvas.setExtent(box) 415 | mCanvas.refresh() 416 | 417 | self.nextButton.setEnabled(True) 418 | self.nextButton.setDefault(True) 419 | self.prevButton.setEnabled(True) 420 | self.assignButton.setEnabled(True) 421 | self.classifiedLabel.setEnabled(True) 422 | self.fidLabel.setEnabled(True) 423 | self.classesCombo.setEnabled(True) 424 | self.goToButton.setEnabled(True) 425 | self.goToTextField.setEnabled(True) 426 | self.classesCombo.setFocus() 427 | self.changeScaleButton.setEnabled(True) 428 | self.scaleOptionsTextLine.setEnabled(True) 429 | self.addClassButton.setEnabled(True) 430 | self.addClassField.setEnabled(True) 431 | self.calcErrorMatrixButton.setEnabled(True) 432 | 433 | self.startButton.setDisabled(True) 434 | self.availLayersCombo.setDisabled(True) 435 | self.classNameCombo.setDisabled(True) 436 | self.classNameOutCombo.setDisabled(True) 437 | self.featProcessedCombo.setDisabled(True) 438 | self.visitProcessedCheckBox.setDisabled(True) 439 | 440 | else: 441 | self.featLayer.commitChanges() 442 | 443 | self.startButton.setEnabled(True) 444 | self.startButton.setDefault(True) 445 | self.availLayersCombo.setEnabled(True) 446 | self.classNameCombo.setEnabled(True) 447 | self.classNameOutCombo.setEnabled(True) 448 | self.featProcessedCombo.setEnabled(True) 449 | self.visitProcessedCheckBox.setEnabled(True) 450 | 451 | self.nextButton.setDisabled(True) 452 | self.prevButton.setDisabled(True) 453 | self.assignButton.setDisabled(True) 454 | self.classifiedLabel.setDisabled(True) 455 | self.classesCombo.setDisabled(True) 456 | self.goToButton.setDisabled(True) 457 | self.goToTextField.setDisabled(True) 458 | self.changeScaleButton.setDisabled(True) 459 | self.scaleOptionsTextLine.setDisabled(True) 460 | self.addClassButton.setDisabled(True) 461 | self.addClassField.setDisabled(True) 462 | 463 | if availFeats: 464 | self.started = True 465 | 466 | def nextFeat(self): 467 | """ Get the next feat """ 468 | if self.started: 469 | if not self.justAssigned: 470 | selectedOutClassIdx = self.classesCombo.currentIndex() 471 | selectedOutClassName = self.classesCombo.itemText(selectedOutClassIdx) 472 | 473 | self.featLayer.changeAttributeValue(self.cFeat.id(), self.selectedClassOutFieldIdx, selectedOutClassName) 474 | self.featLayer.changeAttributeValue(self.cFeat.id(), self.selectedFeatProcessedFieldIdx, 1) 475 | 476 | self.featLayer.commitChanges() 477 | self.featLayer.startEditing() 478 | 479 | self.featLayer.selectByIds([]) 480 | self.justAssigned = False 481 | 482 | ## Move on to the next feature... 483 | self.cFeatN = self.cFeatN + 1 484 | if self.cFeatN < self.numFeats: 485 | self.cFeat = next(self.featIter) 486 | 487 | availFeats = True 488 | if self.onlyGoToUnProcessedFeats: 489 | foundUnProcessedFeat = False 490 | while not foundUnProcessedFeat: 491 | if self.cFeat[self.selectedFeatProcessedFieldIdx] == 0: 492 | foundUnProcessedFeat = True 493 | else: 494 | self.cFeatN = self.cFeatN + 1 495 | if self.cFeatN < self.numFeats: 496 | self.cFeat = next(self.featIter) 497 | else: 498 | availFeats = False 499 | break 500 | 501 | if availFeats: 502 | self.featLayer.selectByIds([self.cFeat.id()]) 503 | self.fidLabel.setText(str(self.cFeat.id()+1) + " of " + str(self.numFeats)) 504 | 505 | cClassName = str(self.cFeat[self.selectedClassFieldIdx]) 506 | self.classifiedLabel.setText(cClassName) 507 | 508 | outClassName = str(self.cFeat[self.selectedClassOutFieldIdx]) 509 | if (outClassName == None) or (outClassName.strip() == "") or (not (outClassName.strip() in self.classNamesList)): 510 | self.classesCombo.setCurrentIndex(self.classNamesList.index(cClassName)) 511 | else: 512 | self.classesCombo.setCurrentIndex(self.classNamesList.index(outClassName)) 513 | 514 | box = self.featLayer.boundingBoxOfSelected() 515 | box = box.buffered(self.cScaleBuffer) 516 | qgisIface = qgis.utils.iface 517 | mCanvas = qgisIface.mapCanvas() 518 | mCanvas.setExtent(box) 519 | mCanvas.refresh() 520 | else: 521 | self.featLayer.commitChanges() 522 | 523 | self.startButton.setEnabled(True) 524 | self.startButton.setDefault(True) 525 | self.availLayersCombo.setEnabled(True) 526 | self.classNameCombo.setEnabled(True) 527 | self.classNameOutCombo.setEnabled(True) 528 | self.featProcessedCombo.setEnabled(True) 529 | self.visitProcessedCheckBox.setEnabled(True) 530 | 531 | self.nextButton.setDisabled(True) 532 | self.prevButton.setDisabled(True) 533 | self.assignButton.setDisabled(True) 534 | self.classifiedLabel.setDisabled(True) 535 | self.classesCombo.setDisabled(True) 536 | self.goToButton.setDisabled(True) 537 | self.goToTextField.setDisabled(True) 538 | self.changeScaleButton.setDisabled(True) 539 | self.scaleOptionsTextLine.setDisabled(True) 540 | self.addClassButton.setDisabled(True) 541 | self.addClassField.setDisabled(True) 542 | 543 | else: 544 | self.featLayer.commitChanges() 545 | 546 | self.startButton.setEnabled(True) 547 | self.startButton.setDefault(True) 548 | self.availLayersCombo.setEnabled(True) 549 | self.classNameCombo.setEnabled(True) 550 | self.classNameOutCombo.setEnabled(True) 551 | self.featProcessedCombo.setEnabled(True) 552 | self.visitProcessedCheckBox.setEnabled(True) 553 | 554 | self.nextButton.setDisabled(True) 555 | self.prevButton.setDisabled(True) 556 | self.assignButton.setDisabled(True) 557 | self.classifiedLabel.setDisabled(True) 558 | self.classesCombo.setDisabled(True) 559 | self.goToButton.setDisabled(True) 560 | self.goToTextField.setDisabled(True) 561 | self.changeScaleButton.setDisabled(True) 562 | self.scaleOptionsTextLine.setDisabled(True) 563 | self.addClassButton.setDisabled(True) 564 | self.addClassField.setDisabled(True) 565 | 566 | 567 | def prevFeat(self): 568 | if self.started: 569 | self.featLayer.selectByIds([]) 570 | 571 | self.featIter = self.featLayer.getFeatures() 572 | self.cFeat = next(self.featIter) 573 | numFeats2Process = self.cFeatN - 1 574 | self.cFeatN = 0 575 | 576 | for i in range(numFeats2Process): 577 | self.cFeat = next(self.featIter) 578 | self.cFeatN = self.cFeatN + 1 579 | 580 | self.featLayer.selectByIds([self.cFeat.id()]) 581 | self.fidLabel.setText(str(self.cFeat.id()+1) + " of " + str(self.numFeats)) 582 | 583 | cClassName = str(self.cFeat[self.selectedClassFieldIdx]) 584 | self.classifiedLabel.setText(cClassName) 585 | 586 | outClassName = str(self.cFeat[self.selectedClassOutFieldIdx]) 587 | if (outClassName == None) or (outClassName.strip() == "") or (not (outClassName.strip() in self.classNamesList)): 588 | self.classesCombo.setCurrentIndex(self.classNamesList.index(cClassName)) 589 | else: 590 | self.classesCombo.setCurrentIndex(self.classNamesList.index(outClassName)) 591 | 592 | box = self.featLayer.boundingBoxOfSelected() 593 | box = box.buffered(self.cScaleBuffer) 594 | qgisIface = qgis.utils.iface 595 | mCanvas = qgisIface.mapCanvas() 596 | mCanvas.setExtent(box) 597 | mCanvas.refresh() 598 | 599 | def assignFeats(self): 600 | if self.started: 601 | selectedOutClassIdx = self.classesCombo.currentIndex() 602 | selectedOutClassName = self.classesCombo.itemText(selectedOutClassIdx) 603 | 604 | selFeats = self.featLayer.selectedFeatures() 605 | for selFeat in selFeats: 606 | self.featLayer.changeAttributeValue(selFeat.id(), self.selectedClassOutFieldIdx, selectedOutClassName) 607 | self.featLayer.changeAttributeValue(selFeat.id(), self.selectedFeatProcessedFieldIdx, 1) 608 | 609 | self.featLayer.commitChanges() 610 | self.featLayer.startEditing() 611 | 612 | self.featLayer.selectByIds([]) 613 | 614 | self.cFeatN = 0 615 | self.featIter = self.featLayer.getFeatures() 616 | self.cFeat = next(self.featIter) 617 | 618 | self.featLayer.selectByIds([self.cFeat.id()]) 619 | self.fidLabel.setText(str(self.cFeat.id()+1) + " of " + str(self.numFeats)) 620 | 621 | self.justAssigned = True 622 | 623 | 624 | 625 | def goToFeat(self): 626 | if self.started: 627 | self.featLayer.selectByIds([]) 628 | 629 | self.featIter = self.featLayer.getFeatures() 630 | self.cFeat = next(self.featIter) 631 | numFeats2Process = int(self.goToTextField.text())-1 632 | if numFeats2Process < 0: 633 | numFeats2Process = 0 634 | elif numFeats2Process >= self.numFeats: 635 | numFeats2Process = self.numFeats-1 636 | self.cFeatN = 0 637 | 638 | for i in range(numFeats2Process): 639 | self.cFeat = next(self.featIter) 640 | self.cFeatN = self.cFeatN + 1 641 | 642 | self.featLayer.selectByIds([self.cFeat.id()]) 643 | self.fidLabel.setText(str(self.cFeat.id()+1) + " of " + str(self.numFeats)) 644 | 645 | cClassName = str(self.cFeat[self.selectedClassFieldIdx]) 646 | self.classifiedLabel.setText(cClassName) 647 | 648 | outClassName = str(self.cFeat[self.selectedClassOutFieldIdx]) 649 | if (outClassName == None) or (outClassName.strip() == "") or (not (outClassName.strip() in self.classNamesList)): 650 | self.classesCombo.setCurrentIndex(self.classNamesList.index(cClassName)) 651 | else: 652 | self.classesCombo.setCurrentIndex(self.classNamesList.index(outClassName)) 653 | 654 | box = self.featLayer.boundingBoxOfSelected() 655 | box = box.buffered(self.cScaleBuffer) 656 | qgisIface = qgis.utils.iface 657 | mCanvas = qgisIface.mapCanvas() 658 | mCanvas.setExtent(box) 659 | mCanvas.refresh() 660 | self.classesCombo.setFocus() 661 | 662 | def addClassName(self): 663 | if self.started: 664 | classNameTmp = self.addClassField.text() 665 | if (not classNameTmp == "") or (not classNameTmp == None): 666 | self.classNamesList.append(classNameTmp) 667 | self.classesCombo.addItem(classNameTmp) 668 | self.classesCombo.setCurrentIndex(self.classNamesList.index(classNameTmp)) 669 | self.classesCombo.setFocus() 670 | 671 | 672 | def updateScale(self): 673 | if self.started: 674 | self.cScaleBuffer = float(self.scaleOptionsTextLine.text()) 675 | 676 | box = self.featLayer.boundingBoxOfSelected() 677 | box = box.buffered(self.cScaleBuffer) 678 | qgisIface = qgis.utils.iface 679 | mCanvas = qgisIface.mapCanvas() 680 | mCanvas.setExtent(box) 681 | mCanvas.refresh() 682 | self.classesCombo.setFocus() 683 | 684 | def finishProcessing(self): 685 | if self.started: 686 | self.featLayer.commitChanges() 687 | 688 | self.startButton.setEnabled(True) 689 | self.startButton.setDefault(True) 690 | self.availLayersCombo.setEnabled(True) 691 | self.classNameCombo.setEnabled(True) 692 | self.classNameOutCombo.setEnabled(True) 693 | self.featProcessedCombo.setEnabled(True) 694 | self.visitProcessedCheckBox.setEnabled(True) 695 | 696 | self.nextButton.setDisabled(True) 697 | self.prevButton.setDisabled(True) 698 | self.assignButton.setDisabled(True) 699 | self.classifiedLabel.setDisabled(True) 700 | self.fidLabel.setDisabled(True) 701 | self.classesCombo.setDisabled(True) 702 | self.goToButton.setDisabled(True) 703 | self.goToTextField.setDisabled(True) 704 | self.changeScaleButton.setDisabled(True) 705 | self.scaleOptionsTextLine.setDisabled(True) 706 | self.addClassButton.setDisabled(True) 707 | self.addClassField.setDisabled(True) 708 | self.started = False 709 | 710 | def calcErrMatrix(self): 711 | if self.started: 712 | self.featLayer.commitChanges() 713 | 714 | self.startButton.setEnabled(True) 715 | self.startButton.setDefault(True) 716 | self.availLayersCombo.setEnabled(True) 717 | self.classNameCombo.setEnabled(True) 718 | self.classNameOutCombo.setEnabled(True) 719 | self.featProcessedCombo.setEnabled(True) 720 | self.visitProcessedCheckBox.setEnabled(True) 721 | 722 | self.nextButton.setDisabled(True) 723 | self.prevButton.setDisabled(True) 724 | self.assignButton.setDisabled(True) 725 | self.classifiedLabel.setDisabled(True) 726 | self.fidLabel.setDisabled(True) 727 | self.classesCombo.setDisabled(True) 728 | self.goToButton.setDisabled(True) 729 | self.goToTextField.setDisabled(True) 730 | self.changeScaleButton.setDisabled(True) 731 | self.scaleOptionsTextLine.setDisabled(True) 732 | self.addClassButton.setDisabled(True) 733 | self.addClassField.setDisabled(True) 734 | self.started = False 735 | 736 | outCSVFilePath = QW.QFileDialog.getSaveFileName(self, 'SaveErrorMatrixCSV', '', 'CSV(*.csv)') #(self, 'Save Error Matrix CSV', '', '*.csv') 737 | if outCSVFilePath: 738 | featsClassNamesImgList = QgsVectorLayerUtils.getValues(self.featLayer, self.selectedClassFieldName)[0] 739 | featsClassNamesGrdList = QgsVectorLayerUtils.getValues(self.featLayer, self.selectedClassOutFieldName)[0] 740 | numClasses = len(self.classNamesList) 741 | 742 | errMatrix = numpy.zeros((numClasses,numClasses), dtype=float) 743 | 744 | for i in range(self.numFeats): 745 | imgClass = featsClassNamesImgList[i] 746 | imgClassIdx = self.classNamesList.index(imgClass) 747 | grdClass = featsClassNamesGrdList[i] 748 | grdClassIdx = self.classNamesList.index(grdClass) 749 | errMatrix[imgClassIdx,grdClassIdx] = errMatrix[imgClassIdx,grdClassIdx] + 1 750 | 751 | errMatrixPercent = (errMatrix / numpy.sum(errMatrix)) * 100 752 | 753 | producerAcc = numpy.zeros(numClasses, dtype=float) 754 | userAcc = numpy.zeros(numClasses, dtype=float) 755 | producerAccCount = numpy.zeros(numClasses, dtype=float) 756 | userAccCount = numpy.zeros(numClasses, dtype=float) 757 | overallCorrCount = 0.0 758 | 759 | for i in range(numClasses): 760 | corVal = float(errMatrix[i,i]) 761 | sumRow = float(numpy.sum(errMatrix[i,])) 762 | sumCol = float(numpy.sum(errMatrix[...,i])) 763 | overallCorrCount = overallCorrCount + corVal 764 | if sumRow == 0: 765 | userAcc[i] = 0 766 | userAccCount[i] = 0 767 | else: 768 | userAcc[i] = corVal / sumRow 769 | userAccCount[i] = sumRow 770 | if sumCol == 0: 771 | producerAcc[i] = 0 772 | producerAccCount[i] = 0 773 | else: 774 | producerAcc[i] = corVal / sumCol 775 | producerAccCount[i] = sumCol 776 | 777 | overallAcc = (overallCorrCount / numpy.sum(errMatrix)) * 100 778 | producerAcc = producerAcc * 100 779 | userAcc = userAcc * 100 780 | 781 | kappaPartA = overallCorrCount * numpy.sum(producerAccCount) 782 | kappaPartB = numpy.sum(userAccCount * producerAccCount) 783 | kappaPartC = numpy.sum(errMatrix) * numpy.sum(errMatrix) 784 | 785 | kappa = float(kappaPartA - kappaPartB) / float(kappaPartC - kappaPartB) 786 | 787 | with open(outCSVFilePath[0], 'w') as csvfile: #(outCSVFilePath, 'wb') 788 | accWriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) 789 | 790 | accWriter.writerow(['Overall Accuracy (%)', round(overallAcc,2)]) 791 | accWriter.writerow(['kappa', round(kappa,2)]) 792 | 793 | accWriter.writerow([]) 794 | accWriter.writerow(['Counts:']) 795 | 796 | colNames = [' '] 797 | for i in range(numClasses): 798 | colNames.append(self.classNamesList[i]) 799 | colNames.append('User') 800 | accWriter.writerow(colNames) 801 | 802 | for i in range(numClasses): 803 | row = [] 804 | row.append(self.classNamesList[i]) 805 | for j in range(numClasses): 806 | row.append(errMatrix[i,j]) 807 | row.append(round(userAccCount[i],2)) 808 | accWriter.writerow(row) 809 | 810 | prodRow = ['Producer'] 811 | for i in range(numClasses): 812 | prodRow.append(round(producerAccCount[i],2)) 813 | prodRow.append(overallCorrCount) 814 | accWriter.writerow(prodRow) 815 | 816 | accWriter.writerow([]) 817 | accWriter.writerow(['Percentage:']) 818 | 819 | colNames = [' '] 820 | for i in range(numClasses): 821 | colNames.append(self.classNamesList[i]) 822 | colNames.append('User (%)') 823 | accWriter.writerow(colNames) 824 | 825 | for i in range(numClasses): 826 | row = [] 827 | row.append(self.classNamesList[i]) 828 | for j in range(numClasses): 829 | row.append(round(errMatrixPercent[i,j],2)) 830 | row.append(round(userAcc[i],2)) 831 | accWriter.writerow(row) 832 | 833 | prodRow = ['Producer (%)'] 834 | for i in range(numClasses): 835 | prodRow.append(round(producerAcc[i],2)) 836 | prodRow.append(round(overallAcc,2)) 837 | accWriter.writerow(prodRow) 838 | 839 | -------------------------------------------------------------------------------- /ClassAccuracyMain/scripts/compile-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LRELEASE=$1 3 | LOCALES=$2 4 | 5 | 6 | for LOCALE in ${LOCALES} 7 | do 8 | echo "Processing: ${LOCALE}.ts" 9 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 10 | # about what is made available. 11 | $LRELEASE i18n/${LOCALE}.ts 12 | done 13 | -------------------------------------------------------------------------------- /ClassAccuracyMain/scripts/run-env-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QGIS_PREFIX_PATH=/usr/local/qgis-2.0 4 | if [ -n "$1" ]; then 5 | QGIS_PREFIX_PATH=$1 6 | fi 7 | 8 | echo ${QGIS_PREFIX_PATH} 9 | 10 | 11 | export QGIS_PREFIX_PATH=${QGIS_PREFIX_PATH} 12 | export QGIS_PATH=${QGIS_PREFIX_PATH} 13 | export LD_LIBRARY_PATH=${QGIS_PREFIX_PATH}/lib 14 | export PYTHONPATH=${QGIS_PREFIX_PATH}/share/qgis/python:${QGIS_PREFIX_PATH}/share/qgis/python/plugins:${PYTHONPATH} 15 | 16 | echo "QGIS PATH: $QGIS_PREFIX_PATH" 17 | export QGIS_DEBUG=0 18 | export QGIS_LOG_FILE=/tmp/inasafe/realtime/logs/qgis.log 19 | 20 | export PATH=${QGIS_PREFIX_PATH}/bin:$PATH 21 | 22 | echo "This script is intended to be sourced to set up your shell to" 23 | echo "use a QGIS 2.0 built in $QGIS_PREFIX_PATH" 24 | echo 25 | echo "To use it do:" 26 | echo "source $BASH_SOURCE /your/optional/install/path" 27 | echo 28 | echo "Then use the make file supplied here e.g. make guitest" 29 | -------------------------------------------------------------------------------- /ClassAccuracyMain/scripts/update-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LOCALES=$* 3 | 4 | # Get newest .py files so we don't update strings unnecessarily 5 | 6 | CHANGED_FILES=0 7 | PYTHON_FILES=`find . -regex ".*\(ui\|py\)$" -type f` 8 | for PYTHON_FILE in $PYTHON_FILES 9 | do 10 | CHANGED=$(stat -c %Y $PYTHON_FILE) 11 | if [ ${CHANGED} -gt ${CHANGED_FILES} ] 12 | then 13 | CHANGED_FILES=${CHANGED} 14 | fi 15 | done 16 | 17 | # Qt translation stuff 18 | # for .ts file 19 | UPDATE=false 20 | for LOCALE in ${LOCALES} 21 | do 22 | TRANSLATION_FILE="i18n/$LOCALE.ts" 23 | if [ ! -f ${TRANSLATION_FILE} ] 24 | then 25 | # Force translation string collection as we have a new language file 26 | touch ${TRANSLATION_FILE} 27 | UPDATE=true 28 | break 29 | fi 30 | 31 | MODIFICATION_TIME=$(stat -c %Y ${TRANSLATION_FILE}) 32 | if [ ${CHANGED_FILES} -gt ${MODIFICATION_TIME} ] 33 | then 34 | # Force translation string collection as a .py file has been updated 35 | UPDATE=true 36 | break 37 | fi 38 | done 39 | 40 | if [ ${UPDATE} == true ] 41 | # retrieve all python files 42 | then 43 | print ${PYTHON_FILES} 44 | # update .ts 45 | echo "Please provide translations by editing the translation files below:" 46 | for LOCALE in ${LOCALES} 47 | do 48 | echo "i18n/"${LOCALE}".ts" 49 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 50 | # about what is made available. 51 | pylupdate4 -noobsolete ${PYTHON_FILES} -ts i18n/${LOCALE}.ts 52 | done 53 | else 54 | echo "No need to edit any translation files (.ts) because no python files" 55 | echo "has been updated since the last update translation. " 56 | fi 57 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/__init__.py: -------------------------------------------------------------------------------- 1 | # import qgis libs so that ve set the correct sip api version 2 | import qgis # pylint: disable=W0611 # NOQA -------------------------------------------------------------------------------- /ClassAccuracyMain/test/qgis_interface.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """QGIS plugin implementation. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | .. note:: This source code was copied from the 'postgis viewer' application 10 | with original authors: 11 | Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk 12 | Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org 13 | Copyright (c) 2014 Tim Sutton, tim@linfiniti.com 14 | 15 | """ 16 | 17 | __author__ = 'tim@linfiniti.com' 18 | __revision__ = '$Format:%H$' 19 | __date__ = '10/01/2011' 20 | __copyright__ = ( 21 | 'Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk and ' 22 | 'Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org' 23 | 'Copyright (c) 2014 Tim Sutton, tim@linfiniti.com' 24 | ) 25 | 26 | import logging 27 | from qgis.PyQt.QtCore import QObject, pyqtSlot, pyqtSignal 28 | from qgis.core import QgsMapLayerRegistry 29 | from qgis.gui import QgsMapCanvasLayer 30 | LOGGER = logging.getLogger('QGIS') 31 | 32 | 33 | #noinspection PyMethodMayBeStatic,PyPep8Naming 34 | class QgisInterface(QObject): 35 | """Class to expose QGIS objects and functions to plugins. 36 | 37 | This class is here for enabling us to run unit tests only, 38 | so most methods are simply stubs. 39 | """ 40 | currentLayerChanged = pyqtSignal(QgsMapCanvasLayer) 41 | 42 | def __init__(self, canvas): 43 | """Constructor 44 | :param canvas: 45 | """ 46 | QObject.__init__(self) 47 | self.canvas = canvas 48 | # Set up slots so we can mimic the behaviour of QGIS when layers 49 | # are added. 50 | LOGGER.debug('Initialising canvas...') 51 | # noinspection PyArgumentList 52 | QgsMapLayerRegistry.instance().layersAdded.connect(self.addLayers) 53 | # noinspection PyArgumentList 54 | QgsMapLayerRegistry.instance().layerWasAdded.connect(self.addLayer) 55 | # noinspection PyArgumentList 56 | QgsMapLayerRegistry.instance().removeAll.connect(self.removeAllLayers) 57 | 58 | # For processing module 59 | self.destCrs = None 60 | 61 | @pyqtSlot('QStringList') 62 | def addLayers(self, layers): 63 | """Handle layers being added to the registry so they show up in canvas. 64 | 65 | :param layers: list list of map layers that were added 66 | 67 | .. note:: The QgsInterface api does not include this method, 68 | it is added here as a helper to facilitate testing. 69 | """ 70 | #LOGGER.debug('addLayers called on qgis_interface') 71 | #LOGGER.debug('Number of layers being added: %s' % len(layers)) 72 | #LOGGER.debug('Layer Count Before: %s' % len(self.canvas.layers())) 73 | current_layers = self.canvas.layers() 74 | final_layers = [] 75 | for layer in current_layers: 76 | final_layers.append(QgsMapCanvasLayer(layer)) 77 | for layer in layers: 78 | final_layers.append(QgsMapCanvasLayer(layer)) 79 | 80 | self.canvas.setLayerSet(final_layers) 81 | #LOGGER.debug('Layer Count After: %s' % len(self.canvas.layers())) 82 | 83 | @pyqtSlot('QgsMapLayer') 84 | def addLayer(self, layer): 85 | """Handle a layer being added to the registry so it shows up in canvas. 86 | 87 | :param layer: list list of map layers that were added 88 | 89 | .. note: The QgsInterface api does not include this method, it is added 90 | here as a helper to facilitate testing. 91 | 92 | .. note: The addLayer method was deprecated in QGIS 1.8 so you should 93 | not need this method much. 94 | """ 95 | pass 96 | 97 | @pyqtSlot() 98 | def removeAllLayers(self): 99 | """Remove layers from the canvas before they get deleted.""" 100 | self.canvas.setLayerSet([]) 101 | 102 | def newProject(self): 103 | """Create new project.""" 104 | # noinspection PyArgumentList 105 | QgsMapLayerRegistry.instance().removeAllMapLayers() 106 | 107 | # ---------------- API Mock for QgsInterface follows ------------------- 108 | 109 | def zoomFull(self): 110 | """Zoom to the map full extent.""" 111 | pass 112 | 113 | def zoomToPrevious(self): 114 | """Zoom to previous view extent.""" 115 | pass 116 | 117 | def zoomToNext(self): 118 | """Zoom to next view extent.""" 119 | pass 120 | 121 | def zoomToActiveLayer(self): 122 | """Zoom to extent of active layer.""" 123 | pass 124 | 125 | def addVectorLayer(self, path, base_name, provider_key): 126 | """Add a vector layer. 127 | 128 | :param path: Path to layer. 129 | :type path: str 130 | 131 | :param base_name: Base name for layer. 132 | :type base_name: str 133 | 134 | :param provider_key: Provider key e.g. 'ogr' 135 | :type provider_key: str 136 | """ 137 | pass 138 | 139 | def addRasterLayer(self, path, base_name): 140 | """Add a raster layer given a raster layer file name 141 | 142 | :param path: Path to layer. 143 | :type path: str 144 | 145 | :param base_name: Base name for layer. 146 | :type base_name: str 147 | """ 148 | pass 149 | 150 | def activeLayer(self): 151 | """Get pointer to the active layer (layer selected in the legend).""" 152 | # noinspection PyArgumentList 153 | layers = QgsMapLayerRegistry.instance().mapLayers() 154 | for item in layers: 155 | return layers[item] 156 | 157 | def addToolBarIcon(self, action): 158 | """Add an icon to the plugins toolbar. 159 | 160 | :param action: Action to add to the toolbar. 161 | :type action: QAction 162 | """ 163 | pass 164 | 165 | def removeToolBarIcon(self, action): 166 | """Remove an action (icon) from the plugin toolbar. 167 | 168 | :param action: Action to add to the toolbar. 169 | :type action: QAction 170 | """ 171 | pass 172 | 173 | def addToolBar(self, name): 174 | """Add toolbar with specified name. 175 | 176 | :param name: Name for the toolbar. 177 | :type name: str 178 | """ 179 | pass 180 | 181 | def mapCanvas(self): 182 | """Return a pointer to the map canvas.""" 183 | return self.canvas 184 | 185 | def mainWindow(self): 186 | """Return a pointer to the main window. 187 | 188 | In case of QGIS it returns an instance of QgisApp. 189 | """ 190 | pass 191 | 192 | def addDockWidget(self, area, dock_widget): 193 | """Add a dock widget to the main window. 194 | 195 | :param area: Where in the ui the dock should be placed. 196 | :type area: 197 | 198 | :param dock_widget: A dock widget to add to the UI. 199 | :type dock_widget: QDockWidget 200 | """ 201 | pass 202 | 203 | def legendInterface(self): 204 | """Get the legend.""" 205 | return self.canvas 206 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/tenbytenraster.asc: -------------------------------------------------------------------------------- 1 | NCOLS 10 2 | NROWS 10 3 | XLLCENTER 1535380.000000 4 | YLLCENTER 5083260.000000 5 | DX 10 6 | DY 10 7 | NODATA_VALUE -9999 8 | 0 1 2 3 4 5 6 7 8 9 9 | 0 1 2 3 4 5 6 7 8 9 10 | 0 1 2 3 4 5 6 7 8 9 11 | 0 1 2 3 4 5 6 7 8 9 12 | 0 1 2 3 4 5 6 7 8 9 13 | 0 1 2 3 4 5 6 7 8 9 14 | 0 1 2 3 4 5 6 7 8 9 15 | 0 1 2 3 4 5 6 7 8 9 16 | 0 1 2 3 4 5 6 7 8 9 17 | 0 1 2 3 4 5 6 7 8 9 18 | CRS 19 | NOTES 20 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/tenbytenraster.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Point 4 | 5 | 6 | 7 | 9 8 | 4.5 9 | 0 10 | 2.872281323269 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/tenbytenraster.keywords: -------------------------------------------------------------------------------- 1 | title: Tenbytenraster 2 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/tenbytenraster.lic: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tim Sutton, Linfiniti Consulting CC 5 | 6 | 7 | 8 | tenbytenraster.asc 9 | 2700044251 10 | Yes 11 | Tim Sutton 12 | Tim Sutton (QGIS Source Tree) 13 | Tim Sutton 14 | This data is publicly available from QGIS Source Tree. The original 15 | file was created and contributed to QGIS by Tim Sutton. 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/tenbytenraster.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /ClassAccuracyMain/test/tenbytenraster.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 0 26 | 27 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/test_init.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests QGIS plugin init.""" 3 | 4 | from future import standard_library 5 | standard_library.install_aliases() 6 | __author__ = 'Tim Sutton ' 7 | __revision__ = '$Format:%H$' 8 | __date__ = '17/10/2010' 9 | __license__ = "GPL" 10 | __copyright__ = 'Copyright 2012, Australia Indonesia Facility for ' 11 | __copyright__ += 'Disaster Reduction' 12 | 13 | import os 14 | import unittest 15 | import logging 16 | import configparser 17 | 18 | LOGGER = logging.getLogger('QGIS') 19 | 20 | 21 | class TestInit(unittest.TestCase): 22 | """Test that the plugin init is usable for QGIS. 23 | 24 | Based heavily on the validator class by Alessandro 25 | Passoti available here: 26 | 27 | http://github.com/qgis/qgis-django/blob/master/qgis-app/ 28 | plugins/validator.py 29 | 30 | """ 31 | 32 | def test_read_init(self): 33 | """Test that the plugin __init__ will validate on plugins.qgis.org.""" 34 | 35 | # You should update this list according to the latest in 36 | # https://github.com/qgis/qgis-django/blob/master/qgis-app/ 37 | # plugins/validator.py 38 | 39 | required_metadata = [ 40 | 'name', 41 | 'description', 42 | 'version', 43 | 'qgisMinimumVersion', 44 | 'email', 45 | 'author'] 46 | 47 | file_path = os.path.abspath(os.path.join( 48 | os.path.dirname(__file__), os.pardir, 49 | 'metadata.txt')) 50 | LOGGER.info(file_path) 51 | metadata = [] 52 | parser = configparser.ConfigParser() 53 | parser.optionxform = str 54 | parser.read(file_path) 55 | message = 'Cannot find a section named "general" in %s' % file_path 56 | assert parser.has_section('general'), message 57 | metadata.extend(parser.items('general')) 58 | 59 | for expectation in required_metadata: 60 | message = ('Cannot find metadata "%s" in metadata source (%s).' % ( 61 | expectation, file_path)) 62 | 63 | self.assertIn(expectation, dict(metadata), message) 64 | 65 | if __name__ == '__main__': 66 | unittest.main() 67 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/test_qgis_environment.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests for QGIS functionality. 3 | 4 | 5 | .. note:: This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | """ 11 | from __future__ import absolute_import 12 | __author__ = 'tim@linfiniti.com' 13 | __date__ = '20/01/2011' 14 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 15 | 'Disaster Reduction') 16 | 17 | import os 18 | import unittest 19 | from qgis.core import ( 20 | QgsProviderRegistry, 21 | QgsCoordinateReferenceSystem, 22 | QgsRasterLayer) 23 | 24 | from .utilities import get_qgis_app 25 | QGIS_APP = get_qgis_app() 26 | 27 | 28 | class QGISTest(unittest.TestCase): 29 | """Test the QGIS Environment""" 30 | 31 | def test_qgis_environment(self): 32 | """QGIS environment has the expected providers""" 33 | 34 | r = QgsProviderRegistry.instance() 35 | self.assertIn('gdal', r.providerList()) 36 | self.assertIn('ogr', r.providerList()) 37 | self.assertIn('postgres', r.providerList()) 38 | 39 | def test_projection(self): 40 | """Test that QGIS properly parses a wkt string. 41 | """ 42 | crs = QgsCoordinateReferenceSystem() 43 | wkt = ( 44 | 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",' 45 | 'SPHEROID["WGS_1984",6378137.0,298.257223563]],' 46 | 'PRIMEM["Greenwich",0.0],UNIT["Degree",' 47 | '0.0174532925199433]]') 48 | crs.createFromWkt(wkt) 49 | auth_id = crs.authid() 50 | expected_auth_id = 'EPSG:4326' 51 | self.assertEqual(auth_id, expected_auth_id) 52 | 53 | # now test for a loaded layer 54 | path = os.path.join(os.path.dirname(__file__), 'tenbytenraster.asc') 55 | title = 'TestRaster' 56 | layer = QgsRasterLayer(path, title) 57 | auth_id = layer.crs().authid() 58 | self.assertEqual(auth_id, expected_auth_id) 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/test_resources.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Resources test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | 11 | __author__ = 'pfb@aber.ac.uk' 12 | __date__ = '2015-08-15' 13 | __copyright__ = 'Copyright 2015, Pete Bunting' 14 | 15 | import unittest 16 | 17 | from qgis.PyQt.QtGui import QIcon 18 | 19 | 20 | 21 | class ClassAccuracyMainDialogTest(unittest.TestCase): 22 | """Test rerources work.""" 23 | 24 | def setUp(self): 25 | """Runs before each test.""" 26 | pass 27 | 28 | def tearDown(self): 29 | """Runs after each test.""" 30 | pass 31 | 32 | def test_icon_png(self): 33 | """Test we can click OK.""" 34 | path = ':/plugins/ClassAccuracyMain/icon.png' 35 | icon = QIcon(path) 36 | self.assertFalse(icon.isNull()) 37 | 38 | if __name__ == "__main__": 39 | suite = unittest.makeSuite(ClassAccuracyMainResourcesTest) 40 | runner = unittest.TextTestRunner(verbosity=2) 41 | runner.run(suite) 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/test_rsgisclassacc_dialog.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Dialog test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | from __future__ import absolute_import 11 | 12 | __author__ = 'pfb@aber.ac.uk' 13 | __date__ = '2015-08-15' 14 | __copyright__ = 'Copyright 2015, Pete Bunting' 15 | 16 | import unittest 17 | 18 | from qgis.PyQt.QtWidgets import QDialogButtonBox, QDialog 19 | 20 | from rsgisclassacc_dialog import ClassAccuracyMainDialog 21 | 22 | from .utilities import get_qgis_app 23 | QGIS_APP = get_qgis_app() 24 | 25 | 26 | class ClassAccuracyMainDialogTest(unittest.TestCase): 27 | """Test dialog works.""" 28 | 29 | def setUp(self): 30 | """Runs before each test.""" 31 | self.dialog = ClassAccuracyMainDialog(None) 32 | 33 | def tearDown(self): 34 | """Runs after each test.""" 35 | self.dialog = None 36 | 37 | def test_dialog_ok(self): 38 | """Test we can click OK.""" 39 | 40 | button = self.dialog.button_box.button(QDialogButtonBox.Ok) 41 | button.click() 42 | result = self.dialog.result() 43 | self.assertEqual(result, QDialog.Accepted) 44 | 45 | def test_dialog_cancel(self): 46 | """Test we can click cancel.""" 47 | button = self.dialog.button_box.button(QDialogButtonBox.Cancel) 48 | button.click() 49 | result = self.dialog.result() 50 | self.assertEqual(result, QDialog.Rejected) 51 | 52 | if __name__ == "__main__": 53 | suite = unittest.makeSuite(ClassAccuracyMainDialogTest) 54 | runner = unittest.TextTestRunner(verbosity=2) 55 | runner.run(suite) 56 | 57 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/test_translations.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Safe Translations Test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | from __future__ import absolute_import 11 | from .utilities import get_qgis_app 12 | 13 | __author__ = 'ismailsunni@yahoo.co.id' 14 | __date__ = '12/10/2011' 15 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 16 | 'Disaster Reduction') 17 | import unittest 18 | import os 19 | 20 | from qgis.PyQt.QtCore import QCoreApplication, QTranslator 21 | 22 | QGIS_APP = get_qgis_app() 23 | 24 | 25 | class SafeTranslationsTest(unittest.TestCase): 26 | """Test translations work.""" 27 | 28 | def setUp(self): 29 | """Runs before each test.""" 30 | if 'LANG' in iter(os.environ.keys()): 31 | os.environ.__delitem__('LANG') 32 | 33 | def tearDown(self): 34 | """Runs after each test.""" 35 | if 'LANG' in iter(os.environ.keys()): 36 | os.environ.__delitem__('LANG') 37 | 38 | def test_qgis_translations(self): 39 | """Test that translations work.""" 40 | parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir) 41 | dir_path = os.path.abspath(parent_path) 42 | file_path = os.path.join( 43 | dir_path, 'i18n', 'af.qm') 44 | translator = QTranslator() 45 | translator.load(file_path) 46 | QCoreApplication.installTranslator(translator) 47 | 48 | expected_message = 'Goeie more' 49 | real_message = QCoreApplication.translate("@default", 'Good morning') 50 | self.assertEqual(real_message, expected_message) 51 | 52 | 53 | if __name__ == "__main__": 54 | suite = unittest.makeSuite(SafeTranslationsTest) 55 | runner = unittest.TextTestRunner(verbosity=2) 56 | runner.run(suite) 57 | -------------------------------------------------------------------------------- /ClassAccuracyMain/test/utilities.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Common functionality used by regression tests.""" 3 | from __future__ import absolute_import 4 | 5 | import sys 6 | import logging 7 | 8 | 9 | LOGGER = logging.getLogger('QGIS') 10 | QGIS_APP = None # Static variable used to hold hand to running QGIS app 11 | CANVAS = None 12 | PARENT = None 13 | IFACE = None 14 | 15 | 16 | def get_qgis_app(): 17 | """ Start one QGIS application to test against. 18 | 19 | :returns: Handle to QGIS app, canvas, iface and parent. If there are any 20 | errors the tuple members will be returned as None. 21 | :rtype: (QgsApplication, CANVAS, IFACE, PARENT) 22 | 23 | If QGIS is already running the handle to that app will be returned. 24 | """ 25 | 26 | try: 27 | from qgis.PyQt import QtGui, QtCore 28 | from qgis.core import QgsApplication 29 | from qgis.gui import QgsMapCanvas 30 | from .qgis_interface import QgisInterface 31 | except ImportError: 32 | return None, None, None, None 33 | 34 | global QGIS_APP # pylint: disable=W0603 35 | 36 | if QGIS_APP is None: 37 | gui_flag = True # All test will run qgis in gui mode 38 | #noinspection PyPep8Naming 39 | QGIS_APP = QgsApplication(sys.argv, gui_flag) 40 | # Make sure QGIS_PREFIX_PATH is set in your env if needed! 41 | QGIS_APP.initQgis() 42 | s = QGIS_APP.showSettings() 43 | LOGGER.debug(s) 44 | 45 | global PARENT # pylint: disable=W0603 46 | if PARENT is None: 47 | #noinspection PyPep8Naming 48 | PARENT = QtGui.QWidget() 49 | 50 | global CANVAS # pylint: disable=W0603 51 | if CANVAS is None: 52 | #noinspection PyPep8Naming 53 | CANVAS = QgsMapCanvas(PARENT) 54 | CANVAS.resize(QtCore.QSize(400, 400)) 55 | 56 | global IFACE # pylint: disable=W0603 57 | if IFACE is None: 58 | # QgisInterface is a stub implementation of the QGIS plugin interface 59 | #noinspection PyPep8Naming 60 | IFACE = QgisInterface(CANVAS) 61 | 62 | return QGIS_APP, CANVAS, IFACE, PARENT 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README # 2 | 3 | This repository is for a QGIS plugin (Class Accuracy) which aims to make is easier to undertake an accuracy assessment of a remote sensing derived classification result. 4 | 5 | The following video demonstrates how to use the plugin (click on image to go to youtube): 6 | [![Using QGIS Class Accuracy Plugin](https://img.youtube.com/vi/npK-Ssq2AYY/0.jpg)](https://www.youtube.com/watch?v=npK-Ssq2AYY "How to use the QGIS Class Accuracy plugin") 7 | 8 | The following video demonstrates how to install the plugin (click on image to go to youtube): 9 | [![Installation QGIS Class Accuracy Plugin](https://img.youtube.com/vi/NJRdKpmujRo/0.jpg)](https://www.youtube.com/watch?v=NJRdKpmujRo "Installation of QGIS Class Accuracy Plugin") 10 | 11 | 12 | 13 | --------------------------------------------------------------------------------