| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,24 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """ | ||
| *************************************************************************** | ||
| __init__.py | ||
| --------------------- | ||
| Date : January 2007 | ||
| Copyright : (C) 2007 by Martin Dobias | ||
| Email : wonder.sk at gmail.com | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| *************************************************************************** | ||
| """ | ||
|
|
||
| __author__ = 'Martin Dobias' | ||
| __date__ = 'January 2007' | ||
| __copyright__ = '(C) 2007, Martin Dobias' | ||
| # This will get replaced with a git SHA1 when you do a git archive | ||
| __revision__ = '$Format:%H$' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,18 @@ | ||
| def name(): | ||
| return "SEXTANTE" | ||
|
|
||
| def description(): | ||
| return "SEXTANTE Geoprocessing Platform for QGIS" | ||
|
|
||
| def version(): | ||
| return "1.0.8" | ||
|
|
||
| def icon(): | ||
| return "images/toolbox.png" | ||
|
|
||
| def qgisMinimumVersion(): | ||
| return "1.0" | ||
|
|
||
| def classFactory(iface): | ||
| from sextante.SextantePlugin import SextantePlugin | ||
| return SextantePlugin(iface) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,46 @@ | ||
| import os | ||
|
|
||
| from PyQt4.QtCore import * | ||
| from PyQt4.QtGui import * | ||
|
|
||
| from sextante.__init__ import version | ||
| from ui_aboutdialogbase import Ui_DlgAbout | ||
|
|
||
| import sextante.resources_rc | ||
|
|
||
| class AboutDialog(QDialog, Ui_DlgAbout): | ||
|
|
||
| def __init__(self): | ||
| QDialog.__init__(self) | ||
| self.setupUi(self) | ||
|
|
||
| self.buttonBox.helpRequested.connect(self.openHelp) | ||
|
|
||
| self.setAboutText() | ||
|
|
||
| def setAboutText(self): | ||
| strAbout = self.tr(""" | ||
| <img src="qrc:/sextante/images/sextante_logo.png" /> | ||
| <h2>SEXTANTE for QGIS</h2> | ||
| <p>SEXTANTE, a geoprocessing platform for QGIS</p> | ||
| <p>A development by Victor Olaya (volayaf@gmail.com).</p> | ||
| <p>Portions of this software contributed by: | ||
| <ul> | ||
| <li>Alexander Bruy</li> | ||
| <li>Carson Farmer (fTools algorithms)</li> | ||
| <li>Julien Malik (Orfeo Toolbox connectors)</li> | ||
| <li>Evgeniy Nikulin (Original Field Pyculator code)</li> | ||
| <li>Michael Nimm (mmqgis algorithms)</li> | ||
| <li>Camilo Polymeris (Threading). Developed as part of Google | ||
| Summer of Code 2012</li> | ||
| </ul> | ||
| </p> | ||
| <p>You are currently using SEXTANTE v%1</p> | ||
| <p>This software is distributed under the terms of the GNU GPL License v2. | ||
| <p>For more information, please visit our website at | ||
| <a href="http://sextantegis.com">http://sextantegis.com</a></p> | ||
| """).arg(version()) | ||
| self.webView.setHtml(strAbout) | ||
|
|
||
| def openHelp(self): | ||
| QDesktopServices.openUrl(QUrl(os.path.join(os.path.dirname(__file__), os.path.pardir) + "/help/index.html")) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| FILE(GLOB PY_FILES *.py) | ||
|
|
||
| FILE(GLOB UI_FILES *.ui) | ||
| PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES}) | ||
|
|
||
| ADD_CUSTOM_TARGET(sextante_about ALL DEPENDS ${PYUI_FILES}) | ||
|
|
||
| INSTALL(FILES ${PY_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR}/about) | ||
| INSTALL(FILES ${PYUI_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR}/about) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>DlgAbout</class> | ||
| <widget class="QDialog" name="DlgAbout"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>492</width> | ||
| <height>401</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>About SEXTANTE</string> | ||
| </property> | ||
| <layout class="QVBoxLayout" name="verticalLayout"> | ||
| <property name="spacing"> | ||
| <number>2</number> | ||
| </property> | ||
| <property name="margin"> | ||
| <number>0</number> | ||
| </property> | ||
| <item> | ||
| <widget class="QWebView" name="webView"> | ||
| <property name="url"> | ||
| <url> | ||
| <string>about:blank</string> | ||
| </url> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QDialogButtonBox" name="buttonBox"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Horizontal</enum> | ||
| </property> | ||
| <property name="standardButtons"> | ||
| <set>QDialogButtonBox::Close|QDialogButtonBox::Help</set> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <customwidgets> | ||
| <customwidget> | ||
| <class>QWebView</class> | ||
| <extends>QWidget</extends> | ||
| <header>QtWebKit/QWebView</header> | ||
| </customwidget> | ||
| </customwidgets> | ||
| <resources/> | ||
| <connections> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>accepted()</signal> | ||
| <receiver>DlgAbout</receiver> | ||
| <slot>accept()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>248</x> | ||
| <y>254</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>157</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>rejected()</signal> | ||
| <receiver>DlgAbout</receiver> | ||
| <slot>reject()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>316</x> | ||
| <y>260</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>286</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| </connections> | ||
| </ui> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,211 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """ | ||
| *************************************************************************** | ||
| BasicStatisticsNumbers.py | ||
| --------------------- | ||
| Date : September 2012 | ||
| Copyright : (C) 2012 by Victor Olaya | ||
| Email : volayaf at gmail dot com | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| *************************************************************************** | ||
| """ | ||
|
|
||
| __author__ = 'Victor Olaya' | ||
| __date__ = 'September 2012' | ||
| __copyright__ = '(C) 2012, Victor Olaya' | ||
| # This will get replaced with a git SHA1 when you do a git archive | ||
| __revision__ = '$Format:%H$' | ||
|
|
||
| import os.path | ||
| import math | ||
|
|
||
| from PyQt4 import QtGui | ||
| from PyQt4.QtCore import * | ||
|
|
||
| from qgis.core import * | ||
|
|
||
| from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
| from sextante.core.QGisLayers import QGisLayers | ||
|
|
||
| from sextante.parameters.ParameterVector import ParameterVector | ||
| from sextante.parameters.ParameterTableField import ParameterTableField | ||
| from sextante.parameters.ParameterBoolean import ParameterBoolean | ||
|
|
||
| from sextante.outputs.OutputHTML import OutputHTML | ||
| from sextante.outputs.OutputNumber import OutputNumber | ||
|
|
||
| from sextante.ftools import FToolsUtils as utils | ||
|
|
||
| class BasicStatisticsNumbers(GeoAlgorithm): | ||
|
|
||
| INPUT_LAYER = "INPUT_LAYER" | ||
| FIELD_NAME = "FIELD_NAME" | ||
| USE_SELECTION = "USE_SELECTION" | ||
| OUTPUT_HTML_FILE = "OUTPUT_HTML_FILE" | ||
|
|
||
| CV = "CV" | ||
| MIN = "MIN" | ||
| MAX = "MAX" | ||
| SUM = "SUM" | ||
| MEAN = "MEAN" | ||
| COUNT = "COUNT" | ||
| RANGE = "RANGE" | ||
| MEDIAN = "MEDIAN" | ||
| UNIQUE = "UNIQUE" | ||
| STD_DEV = "STD_DEV" | ||
|
|
||
| def getIcon(self): | ||
| return QtGui.QIcon(os.path.dirname(__file__) + "/icons/basic_statistics.png") | ||
|
|
||
| def defineCharacteristics(self): | ||
| self.name = "Basic statistics for numeric fields" | ||
| self.group = "Analysis tools" | ||
|
|
||
| self.addParameter(ParameterVector(self.INPUT_LAYER, "Input vector layer", ParameterVector.VECTOR_TYPE_ANY, False)) | ||
| self.addParameter(ParameterTableField(self.FIELD_NAME, "Field to calculate statistics on", self.INPUT_LAYER, ParameterTableField.DATA_TYPE_NUMBER)) | ||
| self.addParameter(ParameterBoolean(self.USE_SELECTION, "Use selection", False)) | ||
|
|
||
| self.addOutput(OutputHTML(self.OUTPUT_HTML_FILE, "Statistics for numeric field")) | ||
|
|
||
| self.addOutput(OutputNumber(self.CV, "Coefficient of Variation")) | ||
| self.addOutput(OutputNumber(self.MIN, "Minimum value")) | ||
| self.addOutput(OutputNumber(self.MAX, "Maximum value")) | ||
| self.addOutput(OutputNumber(self.SUM, "Sum")) | ||
| self.addOutput(OutputNumber(self.MEAN, "Mean value")) | ||
| self.addOutput(OutputNumber(self.COUNT, "Count")) | ||
| self.addOutput(OutputNumber(self.RANGE, "Range")) | ||
| self.addOutput(OutputNumber(self.MEDIAN, "Median")) | ||
| self.addOutput(OutputNumber(self.UNIQUE, "Number of unique values")) | ||
| self.addOutput(OutputNumber(self.STD_DEV, "Standard deviation")) | ||
|
|
||
| def processAlgorithm(self, progress): | ||
| layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER)) | ||
| fieldName = self.getParameterValue(self.FIELD_NAME) | ||
| useSelection = self.getParameterValue(self.USE_SELECTION) | ||
|
|
||
| outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE) | ||
|
|
||
| index = layer.fieldNameIndex(fieldName) | ||
| layer.select([index], QgsRectangle(), False) | ||
|
|
||
| count = 0 | ||
| rValue = 0 | ||
| cvValue = 0 | ||
| minValue = 0 | ||
| maxValue = 0 | ||
| sumValue = 0 | ||
| meanValue = 0 | ||
| medianValue = 0 | ||
| stdDevValue = 0 | ||
| uniqueValue = 0 | ||
|
|
||
| isFirst = True | ||
| values = [] | ||
|
|
||
| if useSelection: | ||
| selection = layer.selectedFeatures() | ||
| count = layer.selectedFeatureCount() | ||
| total = 100.0 / float(count) | ||
| current = 0 | ||
|
|
||
| for f in selection: | ||
| value = float(f.attributeMap()[index].toDouble()[0]) | ||
|
|
||
| if isFirst: | ||
| minValue = value | ||
| maxValue = value | ||
| isFirst = False | ||
| else: | ||
| if value < minValue: | ||
| minValue = value | ||
| if value > maxValue: | ||
| maxValue = value | ||
|
|
||
| values.append(value) | ||
| sumValue += value | ||
|
|
||
| current += 1 | ||
| progress.setPercentage(int(current * total)) | ||
| else: | ||
| count = layer.featureCount() | ||
| total = 100.0 / float(count) | ||
| current = 0 | ||
|
|
||
| ft = QgsFeature() | ||
| while layer.nextFeature(ft): | ||
| value = float(ft.attributeMap()[index].toDouble()[0]) | ||
|
|
||
| if isFirst: | ||
| minValue = value | ||
| maxValue = value | ||
| isFirst = False | ||
| else: | ||
| if value < minValue: | ||
| minValue = value | ||
| if value > maxValue: | ||
| maxValue = value | ||
|
|
||
| values.append( value ) | ||
| sumValue += value | ||
|
|
||
| current += 1 | ||
| progress.setPercentage(int(current * total)) | ||
|
|
||
| # calculate additional values | ||
| rValue = maxValue - minValue | ||
| uniqueValue = utils.getUniqueValuesCount(layer, index, useSelection) | ||
|
|
||
| if count > 0: | ||
| meanValue = sumValue / count | ||
| if meanValue != 0.00: | ||
| for v in values: | ||
| stdDevValue += ((v - meanValue) * (v - meanValue)) | ||
| stdDevValue = math.sqrt(stdDevValue / count) | ||
| cvValue = stdDevValue / meanValue | ||
|
|
||
| if count > 1: | ||
| tmp = values | ||
| tmp.sort() | ||
| # calculate median | ||
| if (count % 2) == 0: | ||
| medianValue = 0.5 * (tmp[(count - 1) / 2] + tmp[count / 2]) | ||
| else: | ||
| medianValue = tmp[(count + 1) / 2 - 1] | ||
|
|
||
| data = [] | ||
| data.append("Count: " + unicode(count)) | ||
| data.append("Unique values: " + unicode(uniqueValue)) | ||
| data.append("Minimum value: " + unicode(minValue)) | ||
| data.append("Maximum value: " + unicode(maxValue)) | ||
| data.append("Range: " + unicode(rValue)) | ||
| data.append("Sum: " + unicode(sumValue)) | ||
| data.append("Mean value: " + unicode(meanValue)) | ||
| data.append("Median value: " + unicode(medianValue)) | ||
| data.append("Standard deviation: " + unicode(stdDevValue)) | ||
| data.append("Coefficient of Variation: " + unicode(cvValue)) | ||
|
|
||
| self.createHTML(outputFile, data) | ||
|
|
||
| self.setOutputValue(self.COUNT, count) | ||
| self.setOutputValue(self.UNIQUE, uniqueValue) | ||
| self.setOutputValue(self.MIN, minValue) | ||
| self.setOutputValue(self.MAX, maxValue) | ||
| self.setOutputValue(self.RANGE, rValue) | ||
| self.setOutputValue(self.SUM, sumValue) | ||
| self.setOutputValue(self.MEAN, meanValue) | ||
| self.setOutputValue(self.MEDIAN, medianValue) | ||
| self.setOutputValue(self.STD_DEV, stdDevValue) | ||
| self.setOutputValue(self.CV, cvValue) | ||
|
|
||
| def createHTML(self, outputFile, algData): | ||
| f = open(outputFile, "w") | ||
| for s in algData: | ||
| f.write("<p>" + str(s) + "</p>") | ||
| f.close() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """ | ||
| *************************************************************************** | ||
| BasicStatisticsStrings.py | ||
| --------------------- | ||
| Date : September 2012 | ||
| Copyright : (C) 2012 by Victor Olaya | ||
| Email : volayaf at gmail dot com | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| *************************************************************************** | ||
| """ | ||
|
|
||
| __author__ = 'Victor Olaya' | ||
| __date__ = 'September 2012' | ||
| __copyright__ = '(C) 2012, Victor Olaya' | ||
| # This will get replaced with a git SHA1 when you do a git archive | ||
| __revision__ = '$Format:%H$' | ||
|
|
||
| import os.path | ||
|
|
||
| from PyQt4 import QtGui | ||
| from PyQt4.QtCore import * | ||
|
|
||
| from qgis.core import * | ||
|
|
||
| from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
| from sextante.core.QGisLayers import QGisLayers | ||
|
|
||
| from sextante.parameters.ParameterVector import ParameterVector | ||
| from sextante.parameters.ParameterTableField import ParameterTableField | ||
| from sextante.parameters.ParameterBoolean import ParameterBoolean | ||
|
|
||
| from sextante.outputs.OutputHTML import OutputHTML | ||
| from sextante.outputs.OutputNumber import OutputNumber | ||
|
|
||
| from sextante.ftools import FToolsUtils as utils | ||
|
|
||
| class BasicStatisticsStrings(GeoAlgorithm): | ||
|
|
||
| INPUT_LAYER = "INPUT_LAYER" | ||
| FIELD_NAME = "FIELD_NAME" | ||
| USE_SELECTION = "USE_SELECTION" | ||
| OUTPUT_HTML_FILE = "OUTPUT_HTML_FILE" | ||
|
|
||
| MIN_LEN = "MIN_LEN" | ||
| MAX_LEN = "MAX_LEN" | ||
| MEAN_LEN = "MEAN_LEN" | ||
| COUNT = "COUNT" | ||
| EMPTY = "EMPTY" | ||
| FILLED = "FILLED" | ||
| UNIQUE = "UNIQUE" | ||
|
|
||
| def getIcon(self): | ||
| return QtGui.QIcon(os.path.dirname(__file__) + "/icons/basic_statistics.png") | ||
|
|
||
| def defineCharacteristics(self): | ||
| self.name = "Basic statistics for text fields" | ||
| self.group = "Analysis tools" | ||
|
|
||
| self.addParameter(ParameterVector(self.INPUT_LAYER, "Input vector layer", ParameterVector.VECTOR_TYPE_ANY, False)) | ||
| self.addParameter(ParameterTableField(self.FIELD_NAME, "Field to calculate statistics on", self.INPUT_LAYER, ParameterTableField.DATA_TYPE_STRING)) | ||
| self.addParameter(ParameterBoolean(self.USE_SELECTION, "Use selection", False)) | ||
|
|
||
| self.addOutput(OutputHTML(self.OUTPUT_HTML_FILE, "Statistics for text field")) | ||
|
|
||
| self.addOutput(OutputNumber(self.MIN_LEN, "Minimum length")) | ||
| self.addOutput(OutputNumber(self.MAX_LEN, "Maximum length")) | ||
| self.addOutput(OutputNumber(self.MEAN_LEN, "Mean length")) | ||
| self.addOutput(OutputNumber(self.COUNT, "Count")) | ||
| self.addOutput(OutputNumber(self.EMPTY, "Number of empty values")) | ||
| self.addOutput(OutputNumber(self.FILLED, "Number of non-empty values")) | ||
| self.addOutput(OutputNumber(self.UNIQUE, "Number of unique values")) | ||
|
|
||
| def processAlgorithm(self, progress): | ||
| layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER)) | ||
| fieldName = self.getParameterValue(self.FIELD_NAME) | ||
| useSelection = self.getParameterValue(self.USE_SELECTION) | ||
|
|
||
| outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE) | ||
|
|
||
| index = layer.fieldNameIndex(fieldName) | ||
| layer.select([index], QgsRectangle(), False) | ||
|
|
||
| count = 0 | ||
| sumValue = 0 | ||
| minValue = 0 | ||
| maxValue = 0 | ||
| meanValue = 0 | ||
| countEmpty = 0 | ||
| countFilled = 0 | ||
|
|
||
| isFirst = True | ||
| values = [] | ||
|
|
||
| if useSelection: | ||
| selection = layer.selectedFeatures() | ||
| count = layer.selectedFeatureCount() | ||
| total = 100.0 / float(count) | ||
| current = 0 | ||
|
|
||
| for f in selection: | ||
| length = float(len(f.attributeMap()[index].toString())) | ||
|
|
||
| if isFirst: | ||
| minValue = length | ||
| maxValue = length | ||
| isFirst = False | ||
| else: | ||
| if length < minValue: | ||
| minValue = length | ||
| if length > maxValue: | ||
| maxValue = length | ||
|
|
||
| if length != 0.00: | ||
| countFilled += 1 | ||
| else: | ||
| countEmpty += 1 | ||
|
|
||
| values.append(length) | ||
| sumValue += length | ||
|
|
||
| current += 1 | ||
| progress.setPercentage(int(current * total)) | ||
| else: | ||
| count = layer.featureCount() | ||
| total = 100.0 / float(count) | ||
| current = 0 | ||
|
|
||
| ft = QgsFeature() | ||
| while layer.nextFeature(ft): | ||
| length = float(len(ft.attributeMap()[index].toString())) | ||
|
|
||
| if isFirst: | ||
| minValue = length | ||
| maxValue = length | ||
| isFirst = False | ||
| else: | ||
| if length < minValue: | ||
| minValue = length | ||
| if length > maxValue: | ||
| maxValue = length | ||
|
|
||
| if length != 0.00: | ||
| countFilled += 1 | ||
| else: | ||
| countEmpty += 1 | ||
|
|
||
| values.append(length) | ||
| sumValue += length | ||
|
|
||
| current += 1 | ||
| progress.setPercentage(int(current * total)) | ||
|
|
||
| n = float(len(values)) | ||
| if n > 0: | ||
| meanValue = sumValue / n | ||
|
|
||
| uniqueValues = utils.getUniqueValuesCount(layer, index, useSelection) | ||
|
|
||
| data = [] | ||
| data.append("Minimum length: " + unicode(minValue)) | ||
| data.append("Maximum length: " + unicode(maxValue)) | ||
| data.append("Mean length: " + unicode(meanValue)) | ||
| data.append("Filled: " + unicode(countFilled)) | ||
| data.append("Empty: " + unicode(countEmpty)) | ||
| data.append("Count: " + unicode(count)) | ||
| data.append("Unique: " + unicode(uniqueValues)) | ||
|
|
||
| self.createHTML(outputFile, data) | ||
|
|
||
| self.setOutputValue(self.MIN_LEN, minValue) | ||
| self.setOutputValue(self.MAX_LEN, maxValue) | ||
| self.setOutputValue(self.MEAN_LEN, meanValue) | ||
| self.setOutputValue(self.FILLED, countFilled) | ||
| self.setOutputValue(self.EMPTY, countEmpty) | ||
| self.setOutputValue(self.COUNT, count) | ||
| self.setOutputValue(self.UNIQUE, uniqueValues) | ||
|
|
||
| def createHTML(self, outputFile, algData): | ||
| f = open(outputFile, "w") | ||
| for s in algData: | ||
| f.write("<p>" + str(s) + "</p>") | ||
| f.close() |