-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpointSamplingTool.py
74 lines (60 loc) · 2.89 KB
/
pointSamplingTool.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
# -*- coding: utf-8 -*-
# ***************************************************************************
# Point Sampling Tool
#
# A QGIS plugin for collecting polygon attributes and raster values
# from multiple layers at specified sampling points
#
# Copyright (C) 2008 Borys Jurgiel
# based on Carson Farmer's PointsInPoly plugin, Copyright (C) 2008 Carson Farmer
#
# ***************************************************************************
# * *
# * 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. *
# * *
# ***************************************************************************
from builtins import object
from PyQt5.QtCore import qVersion, QCoreApplication, QLocale, QSettings, QTranslator
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QAction
from qgis.core import *
from . import resources
from . import doPointSamplingTool
import os
class pointSamplingTool(object):
def __init__(self, iface):
self.iface = iface
if QSettings().value('locale/overrideFlag', type=bool):
locale = QSettings().value('locale/userLocale')
else:
locale = QLocale.system().name()
locale_path = os.path.join(
os.path.dirname(__file__),
'i18n',
'pointSamplingTool_{}.qm'.format(locale[0:2]))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
QCoreApplication.installTranslator(self.translator)
def initGui(self):
# create action
self.action = QAction(QIcon(":/plugins/pointSamplingTool/pointSamplingToolIcon.png"),
QCoreApplication.translate('Point Sampling Tool', 'Point Sampling Tool'),
self.iface.mainWindow())
self.action.setWhatsThis(QCoreApplication.translate('Point Sampling Tool',
'Collects polygon attributes and raster values from multiple layers at specified sampling points'))
self.action.triggered.connect(self.run)
# add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(QCoreApplication.translate('Point Sampling Tool', "&Analyses"), self.action)
def unload(self):
# remove the plugin menu item and icon
self.iface.removePluginMenu(QCoreApplication.translate('Point Sampling Tool', "&Analyses"), self.action)
self.iface.removeToolBarIcon(self.action)
def run(self):
# create and show a configuration dialog or something similar
dialoga = doPointSamplingTool.Dialog(self.iface)
dialoga.exec_()