Skip to content

Commit e8519a4

Browse files
author
brushtyler
committed
added GdalTools plugin
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13639 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e8d06ff commit e8519a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+7635
-1
lines changed

python/plugins/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SUBDIRS(plugin_installer mapserver_export fTools osm)
1+
SUBDIRS(plugin_installer mapserver_export fTools GdalTools osm)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FILE(GLOB INSTALLER_FILES *.py)
2+
SET(INSTALLER_FILES ${INSTALLER_FILES})
3+
4+
FILE(GLOB UI_FILES *.ui)
5+
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})
6+
PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)
7+
ADD_CUSTOM_TARGET(gdaltools ALL DEPENDS ${PYUI_FILES} ${PYRC_FILES})
8+
9+
SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES})
10+
11+
INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools)
12+
13+
SUBDIRS(tools icons)
14+

python/plugins/GdalTools/GdalTools.py

+277
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
/***************************************************************************
4+
Name : GdalTools
5+
Description : Integrate gdal tools into qgis
6+
Date : 17/Sep/09
7+
copyright : (C) 2009 by Lorenzo Masini (Faunalia)
8+
email : lorenxo86@gmail.com
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+
# Import the PyQt and QGIS libraries
21+
from PyQt4.QtCore import *
22+
from PyQt4.QtGui import *
23+
from qgis.core import *
24+
25+
# Initialize Qt resources from file resources_rc.py
26+
import resources_rc
27+
28+
# Import required modules and if missing show the right name of them
29+
req_mods = { "osgeo": "osgeo [python-gdal]" }
30+
for k, v in req_mods.iteritems():
31+
try:
32+
exec( "import %s" % k )
33+
except ImportError, e:
34+
errorStr = str(e)
35+
if len(v) > 0:
36+
errorStr = errorStr.replace( k, v )
37+
raise ImportError( errorStr )
38+
39+
# Set up current path, so that we know where to look for modules
40+
import os.path, sys
41+
currentPath = os.path.dirname( __file__ )
42+
sys.path.append( os.path.abspath(os.path.dirname( __file__ ) + '/tools' ) )
43+
import doBuildVRT, doContour, doRasterize, doPolygonize, doMerge, doSieve, doProximity, doNearBlack, doWarp, doGrid, doTranslate, doClipper
44+
import doInfo, doProjection, doOverview, doRgbPct, doPctRgb, doSettings, doAbout
45+
46+
import GdalTools_utils as Utils
47+
48+
class GdalTools:
49+
50+
def __init__( self, iface ):
51+
# Save reference to the QGIS interface
52+
self.iface = iface
53+
try:
54+
self.QgisVersion = unicode( QGis.QGIS_VERSION_INT )
55+
except:
56+
self.QgisVersion = unicode( QGis.qgisVersion )[ 0 ]
57+
58+
# For i18n support
59+
userPluginPath = QFileInfo( QgsApplication.qgisUserDbFilePath() ).path() + "/python/plugins/GdalTools"
60+
systemPluginPath = QgsApplication.prefixPath() + "/python/plugins/GdalTools"
61+
62+
overrideLocale = QSettings().value( "locale/overrideFlag", QVariant( False ) ).toBool()
63+
if not overrideLocale:
64+
localeFullName = QLocale.system().name()
65+
else:
66+
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
67+
68+
if QFileInfo( userPluginPath ).exists():
69+
translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
70+
else:
71+
translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
72+
73+
self.localePath = translationPath
74+
if QFileInfo( self.localePath ).exists():
75+
self.translator = QTranslator()
76+
self.translator.load( self.localePath )
77+
QCoreApplication.installTranslator( self.translator )
78+
79+
def initGui( self ):
80+
if int( self.QgisVersion ) < 1:
81+
QMessageBox.warning( self.iface.getMainWindow(), "Gdal Tools",
82+
QCoreApplication.translate( "GdalTools", "Quantum GIS version detected: " ) +unicode( self.QgisVersion )+".xx\n"
83+
+ QCoreApplication.translate( "GdalTools", "This version of Gdal Tools requires at least QGIS version 1.0.0\nPlugin will not be enabled." ) )
84+
return None
85+
86+
self.GdalVersion = Utils.Version( Utils.GdalConfig.version() )
87+
88+
self.menu = QMenu()
89+
self.menu.setTitle( QCoreApplication.translate( "GdalTools", "&Raster" ) )
90+
91+
if self.GdalVersion >= "1.6":
92+
self.buildVRT = QAction( QIcon(":/icons/vrt.png"), QCoreApplication.translate( "GdalTools", "Build Virtual Raster (catalog)" ), self.iface.mainWindow() )
93+
self.buildVRT.setStatusTip( QCoreApplication.translate( "GdalTools", "Builds a VRT from a list of datasets") )
94+
QObject.connect( self.buildVRT, SIGNAL( "triggered()" ), self.doBuildVRT )
95+
self.menu.addAction(self.buildVRT)
96+
97+
if self.GdalVersion >= "1.6":
98+
self.contour = QAction( QIcon(":/icons/contour.png"), QCoreApplication.translate( "GdalTools", "Contour" ), self.iface.mainWindow() )
99+
self.contour.setStatusTip( QCoreApplication.translate( "GdalTools", "Builds vector contour lines from a DEM") )
100+
QObject.connect( self.contour, SIGNAL( "triggered()" ), self.doContour )
101+
self.menu.addAction(self.contour)
102+
103+
if self.GdalVersion >= "1.3":
104+
self.rasterize = QAction( QIcon(":/icons/rasterize.png"), QCoreApplication.translate( "GdalTools", "Rasterize" ), self.iface.mainWindow() )
105+
self.rasterize.setStatusTip( QCoreApplication.translate( "GdalTools", "Burns vector geometries into a raster") )
106+
QObject.connect( self.rasterize, SIGNAL( "triggered()" ), self.doRasterize )
107+
self.menu.addAction(self.rasterize)
108+
109+
if self.GdalVersion >= "1.6":
110+
self.polygonize = QAction( QIcon(":/icons/polygonize.png"), QCoreApplication.translate( "GdalTools", "Polygonize" ), self.iface.mainWindow() )
111+
self.polygonize.setStatusTip( QCoreApplication.translate( "GdalTools", "Produces a polygon feature layer from a raster") )
112+
QObject.connect( self.polygonize, SIGNAL( "triggered()" ), self.doPolygonize )
113+
self.menu.addAction(self.polygonize)
114+
115+
self.merge = QAction( QIcon(":/icons/merge.png"), QCoreApplication.translate( "GdalTools", "Merge" ), self.iface.mainWindow() )
116+
self.merge.setStatusTip( QCoreApplication.translate( "GdalTools", "Build a quick mosaic from a set of images") )
117+
QObject.connect( self.merge, SIGNAL( "triggered()" ), self.doMerge )
118+
self.menu.addAction(self.merge)
119+
120+
if self.GdalVersion >= "1.6":
121+
self.sieve = QAction( QIcon(":/icons/sieve.png"), QCoreApplication.translate( "GdalTools", "Sieve" ), self.iface.mainWindow() )
122+
self.sieve.setStatusTip( QCoreApplication.translate( "GdalTools", "Removes small raster polygons") )
123+
QObject.connect( self.sieve, SIGNAL( "triggered()" ), self.doSieve )
124+
self.menu.addAction(self.sieve)
125+
126+
if self.GdalVersion >= "1.6":
127+
self.proximity = QAction( QIcon(":/icons/proximity.png"), QCoreApplication.translate( "GdalTools", "Proximity" ), self.iface.mainWindow() )
128+
self.proximity.setStatusTip( QCoreApplication.translate( "GdalTools", "Produces a raster proximity map") )
129+
QObject.connect( self.proximity, SIGNAL( "triggered()" ), self.doProximity )
130+
self.menu.addAction(self.proximity)
131+
132+
if self.GdalVersion >= "1.5":
133+
self.nearBlack = QAction( QIcon(":/icons/nearblack.png"), QCoreApplication.translate( "GdalTools", "Near black" ), self.iface.mainWindow() )
134+
self.nearBlack.setStatusTip( QCoreApplication.translate( "GdalTools", "Convert nearly black/white borders to exact value") )
135+
QObject.connect( self.nearBlack, SIGNAL( "triggered()" ), self.doNearBlack )
136+
self.menu.addAction(self.nearBlack)
137+
138+
self.warp = QAction( QIcon(":/icons/warp.png"), QCoreApplication.translate( "GdalTools", "Warp" ), self.iface.mainWindow() )
139+
self.warp.setStatusTip( QCoreApplication.translate( "GdalTools", "Warp an image into a new coordinate system") )
140+
QObject.connect( self.warp, SIGNAL( "triggered()" ), self.doWarp )
141+
self.menu.addAction(self.warp)
142+
143+
if self.GdalVersion >= "1.5":
144+
self.grid = QAction( QIcon(":/icons/grid.png"), QCoreApplication.translate( "GdalTools", "Grid" ), self.iface.mainWindow() )
145+
self.grid.setStatusTip( QCoreApplication.translate( "GdalTools", "Create raster from the scattered data") )
146+
QObject.connect( self.grid, SIGNAL( "triggered()" ), self.doGrid )
147+
self.menu.addAction(self.grid)
148+
149+
self.translate = QAction( QIcon(":/icons/translate.png"), QCoreApplication.translate( "GdalTools", "Translate" ), self.iface.mainWindow() )
150+
self.translate.setStatusTip( QCoreApplication.translate( "GdalTools", "Converts raster data between different formats") )
151+
QObject.connect( self.translate, SIGNAL( "triggered()" ), self.doTranslate )
152+
self.menu.addAction(self.translate)
153+
154+
self.info = QAction( QIcon( ":/icons/raster-info.png" ), QCoreApplication.translate( "GdalTools", "Information" ), self.iface.mainWindow() )
155+
self.info.setStatusTip( QCoreApplication.translate( "GdalTools", "Lists information about raster dataset" ) )
156+
QObject.connect( self.info, SIGNAL("triggered()"), self.doInfo )
157+
self.menu.addAction( self.info )
158+
159+
self.projection = QAction( QIcon( ":icons/projection-add.png" ), QCoreApplication.translate( "GdalTools", "Assign projection" ), self.iface.mainWindow() )
160+
self.projection.setStatusTip( QCoreApplication.translate( "GdalTools", "Add projection info to the raster" ) )
161+
QObject.connect( self.projection, SIGNAL( "triggered()" ), self.doProjection )
162+
self.menu.addAction( self.projection )
163+
164+
self.overview = QAction( QIcon( ":icons/raster-overview.png" ), QCoreApplication.translate( "GdalTools", "Build overviews" ), self.iface.mainWindow() )
165+
self.overview.setStatusTip( QCoreApplication.translate( "GdalTools", "Builds or rebuilds overview images" ) )
166+
QObject.connect( self.overview, SIGNAL( "triggered()" ), self.doOverview )
167+
self.menu.addAction( self.overview )
168+
169+
self.clipper = QAction( QIcon( ":icons/raster-clip.png" ), QCoreApplication.translate( "GdalTools", "Clipper" ), self.iface.mainWindow() )
170+
#self.clipper.setStatusTip( QCoreApplication.translate( "GdalTools", "Converts raster data between different formats") )
171+
QObject.connect( self.clipper, SIGNAL( "triggered()" ), self.doClipper )
172+
self.menu.addAction(self.clipper)
173+
174+
self.paletted = QAction( QIcon( ":icons/raster-paletted.png" ), QCoreApplication.translate( "GdalTools", "RGB to PCT" ), self.iface.mainWindow() )
175+
self.paletted.setStatusTip( QCoreApplication.translate( "GdalTools", "Convert a 24bit RGB image to 8bit paletted" ) )
176+
QObject.connect( self.paletted, SIGNAL( "triggered()" ), self.doPaletted )
177+
self.menu.addAction(self.paletted)
178+
179+
self.rgb = QAction( QIcon( ":icons/raster-paletted.png" ), QCoreApplication.translate( "GdalTools", "PCT to RGB" ), self.iface.mainWindow() )
180+
self.rgb.setStatusTip( QCoreApplication.translate( "GdalTools", "Convert an 8bit paletted image to 24bit RGB" ) )
181+
QObject.connect( self.rgb, SIGNAL( "triggered()" ), self.doRGB )
182+
self.menu.addAction(self.rgb)
183+
184+
self.settings = QAction( QCoreApplication.translate( "GdalTools", "GdalTools settings" ), self.iface.mainWindow() )
185+
self.settings.setStatusTip( QCoreApplication.translate( "GdalTools", "Various settings for Gdal Tools" ) )
186+
QObject.connect( self.settings, SIGNAL( "triggered()" ), self.doSettings )
187+
self.menu.addAction( self.settings )
188+
189+
self.about = QAction( QIcon( ":icons/about.png" ), QCoreApplication.translate( "GdalTools", "About GdalTools" ), self.iface.mainWindow() )
190+
self.about.setStatusTip( QCoreApplication.translate( "GdalTools", "Displays information about Gdal Tools" ) )
191+
QObject.connect( self.about, SIGNAL( "triggered()" ), self.doAbout )
192+
self.menu.addSeparator()
193+
self.menu.addAction( self.about )
194+
195+
menu_bar = self.iface.mainWindow().menuBar()
196+
actions = menu_bar.actions()
197+
lastAction = actions[ len( actions ) - 1 ]
198+
menu_bar.insertMenu( lastAction, self.menu )
199+
200+
def unload( self ):
201+
pass
202+
203+
def doBuildVRT( self ):
204+
d = doBuildVRT.GdalToolsDialog( self.iface )
205+
d.show_()
206+
207+
def doContour( self ):
208+
d = doContour.GdalToolsDialog( self.iface )
209+
d.show_()
210+
211+
def doRasterize( self ):
212+
d = doRasterize.GdalToolsDialog( self.iface )
213+
d.show_()
214+
215+
def doPolygonize( self ):
216+
d = doPolygonize.GdalToolsDialog( self.iface )
217+
d.show_()
218+
219+
def doMerge( self ):
220+
d = doMerge.GdalToolsDialog( self.iface )
221+
d.show_()
222+
223+
def doSieve( self ):
224+
d = doSieve.GdalToolsDialog( self.iface )
225+
d.show_()
226+
227+
def doProximity( self ):
228+
d = doProximity.GdalToolsDialog( self.iface )
229+
d.show_()
230+
231+
def doNearBlack( self ):
232+
d = doNearBlack.GdalToolsDialog( self.iface )
233+
d.show_()
234+
235+
def doWarp( self ):
236+
d = doWarp.GdalToolsDialog( self.iface )
237+
d.show_()
238+
239+
def doGrid( self ):
240+
d = doGrid.GdalToolsDialog( self.iface )
241+
d.show_()
242+
243+
def doTranslate( self ):
244+
d = doTranslate.GdalToolsDialog( self.iface )
245+
d.show_()
246+
247+
def doInfo( self ):
248+
d = doInfo.GdalToolsDialog( self.iface )
249+
d.show_()
250+
251+
def doProjection( self ):
252+
d = doProjection.GdalToolsDialog( self.iface )
253+
d.show_()
254+
255+
def doOverview( self ):
256+
d = doOverview.GdalToolsDialog( self.iface )
257+
d.show_()
258+
259+
def doClipper( self ):
260+
d = doClipper.GdalToolsDialog( self.iface )
261+
d.show_()
262+
263+
def doPaletted( self ):
264+
d = doRgbPct.GdalToolsDialog( self.iface )
265+
d.show_()
266+
267+
def doRGB( self ):
268+
d = doPctRgb.GdalToolsDialog( self.iface )
269+
d.show_()
270+
271+
def doSettings( self ):
272+
d = doSettings.GdalToolsSettingsDialog( self.iface )
273+
d.exec_()
274+
275+
def doAbout( self ):
276+
d = doAbout.GdalToolsAboutDialog( self.iface )
277+
d.exec_()

python/plugins/GdalTools/LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2009 Faunalia
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
20+
21+
You should have received a copy of the GNU General Public License along
22+
with this program; if not, write to the Free Software Foundation, Inc.,
23+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24+

python/plugins/GdalTools/__init__.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
/***************************************************************************
3+
Name : GdalTools
4+
Description : Integrate gdal tools into qgis
5+
Date : 17/Sep/09
6+
copyright : (C) 2009 by Lorenzo Masini and Giuseppe Sucameli (Faunalia)
7+
email : lorenxo86@gmail.com - brush.tyler@gmail.com
8+
***************************************************************************/
9+
10+
/***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************/
18+
This script initializes the plugin, making it known to QGIS.
19+
"""
20+
def name():
21+
return "GdalTools"
22+
def description():
23+
return "Integrate gdal tools into qgis"
24+
def version():
25+
return "Version 1.2.0"
26+
def qgisMinimumVersion():
27+
return "1.0"
28+
def classFactory(iface):
29+
# load GdalTools class from file GdalTools
30+
from GdalTools import GdalTools
31+
return GdalTools(iface)
32+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FILE(GLOB ICON_FILES *.png)
2+
INSTALL(FILES ${ICON_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools/icons)
2.18 KB
Loading
995 Bytes
Loading
433 Bytes
Loading
923 Bytes
Loading
418 Bytes
Loading
827 Bytes
Loading
Loading
940 Bytes
Loading
591 Bytes
Loading
866 Bytes
Loading
845 Bytes
Loading
Loading
1.55 KB
Loading
646 Bytes
Loading
566 Bytes
Loading
582 Bytes
Loading
753 Bytes
Loading
1.24 KB
Loading
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<RCC>
2+
<qresource>
3+
<file>icons/contour.png</file>
4+
<file>icons/merge.png</file>
5+
<file>icons/polygonize.png</file>
6+
<file>icons/rasterize.png</file>
7+
<file>icons/sieve.png</file>
8+
<file>icons/vrt.png</file>
9+
<file>icons/warp.png</file>
10+
<file>icons/proximity.png</file>
11+
<file>icons/nearblack.png</file>
12+
<file>icons/grid.png</file>
13+
<file>icons/translate.png</file>
14+
<file>icons/raster-info.png</file>
15+
<file>icons/projection-add.png</file>
16+
<file>icons/raster-overview.png</file>
17+
<file>icons/raster-clip.png</file>
18+
<file>icons/raster-paletted.png</file>
19+
<file>icons/raster-rgb.png</file>
20+
<file>icons/about.png</file>
21+
</qresource>
22+
</RCC>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FILE(GLOB PY_FILES *.py)
2+
FILE(GLOB UI_FILES *.ui)
3+
4+
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})
5+
6+
ADD_CUSTOM_TARGET(gdaltools_tools ALL DEPENDS ${PYUI_FILES})
7+
8+
INSTALL(FILES ${PY_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools/tools)
9+
INSTALL(FILES ${PYUI_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools/tools)

0 commit comments

Comments
 (0)