-
Notifications
You must be signed in to change notification settings - Fork 2
/
landsatprocessingplugin.py
108 lines (87 loc) · 4.12 KB
/
landsatprocessingplugin.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# -*- coding: utf-8 -*-
"""
/***************************************************************************
landsatProcessingPlugin
A QGIS plugin
Provides several processing steps on Landsat data. Landsat5 to Landsat7 conversion, DNs to radiance and reflectance conversion, TIR to temperature conversion, Indice calculation(NDVI, SAVI, NDWI, NDSI, tasseled cap indices)
-------------------
begin : 2013-02-14
copyright : (C) 2013 by Matthias Ludwig - Datalyze Solutions
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
"""
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
# Initialize Qt resources from file resources.py
import resources_rc
# Import the code for the dialog
from landsatprocessingplugindialog import landsatProcessingPluginDialog
class landsatProcessingPlugin:
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/landsatprocessingplugin"
# initialize locale
localePath = ""
locale = QSettings().value("locale/userLocale").toString()[0:2]
if QFileInfo(self.plugin_dir).exists():
localePath = self.plugin_dir + "/i18n/landsatprocessingplugin_" + locale + ".qm"
if QFileInfo(localePath).exists():
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = landsatProcessingPluginDialog()
def initGui(self):
# Create action that will start plugin configuration
self.action = QAction(
QIcon(":/plugins/landsatprocessingplugin/icon.png"),
u"Landsat Processing Plugin", self.iface.mainWindow())
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(u"&Landsat Processing Plugin", self.action)
self.action.triggered.connect(self.run)
self.dlg.filestuff.sendFilename.connect(self.test)
self.dlg.filestuff.doNothingSignal.connect(self.test2)
#print self.dlg.filestuff
#QObject.connect(self.dlg, SIGNAL("xyCoordinates(const QString &)"), self.test)
# start real work
#self.getFile()
def test(self, text):
print text
def test2(self):
print "eigenes signal emitiert"
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(u"&Landsat Processing Plugin", self.action)
self.iface.removeToolBarIcon(self.action)
def run(self):
self.dlg.show()
#self.dlg.test()
class landsatMetadata():
def __init__(self, filepath, viewWidget):
self.filepath = filepath
self.viewWidget = viewWidget
self.metadata = None
self.lastChangedDate = os.filepathDate
def isUpToDate(self):
if self.lastChangedDate != os.filepathDate:
self.parseMetadata()
self.lastChangedDate
self.lastChangedDate = os.filepathDate
def parseMetadata(self):
self.metadata = parserErgebnis
def updateView(self):
self.viewWidget.update(self.metadata)