[processing] replace fTools and GdalTools plugins with Processing

This commit is contained in:
Alexander Bruy 2016-01-27 15:00:13 +02:00
parent 7823a5a857
commit 5df0ce04e8
257 changed files with 295 additions and 40415 deletions

View File

@ -565,6 +565,7 @@
<file>icons/qgis-icon-16x16_xmas.png</file>
<file>icons/qgis-icon-60x60_xmas.png</file>
<file>themes/default/mActionTracing.png</file>
<file>themes/default/vector_grid.png</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>

View File

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

View File

@ -7,8 +7,6 @@
# Please don't remove this header. #
################################################################################
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS2\PythonPlugins" "fTools" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS2\PythonPlugins" "GdalTools" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS2\PythonPlugins" "db_manager" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS2\PythonPlugins" "processing" "true"

View File

@ -49,8 +49,8 @@ MACRO (PLUGIN_INSTALL plugin subdir )
ENDFOREACH(file)
ENDMACRO (PLUGIN_INSTALL)
ADD_SUBDIRECTORY(fTools)
ADD_SUBDIRECTORY(GdalTools)
#ADD_SUBDIRECTORY(fTools)
#ADD_SUBDIRECTORY(GdalTools)
ADD_SUBDIRECTORY(db_manager)
ADD_SUBDIRECTORY(processing)
ADD_SUBDIRECTORY(MetaSearch)

View File

@ -1,15 +0,0 @@
FILE(GLOB INSTALLER_FILES *.py)
SET(INSTALLER_FILES ${INSTALLER_FILES})
FILE(GLOB UI_FILES *.ui)
PYQT_WRAP_UI(PYUI_FILES ${UI_FILES})
PYQT_ADD_RESOURCES(PYRC_FILES resources.qrc)
#ADD_CUSTOM_TARGET(gdaltools ALL DEPENDS ${PYUI_FILES} ${PYRC_FILES})
SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES})
#INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools)
PLUGIN_INSTALL(GdalTools . ${INSTALLER_FILES} __init__.py metadata.txt)
ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(icons)

View File

@ -1,421 +0,0 @@
# -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : GdalTools
Description : Integrate gdal tools into qgis
Date : 17/Sep/09
copyright : (C) 2009 by Lorenzo Masini (Faunalia)
email : lorenxo86@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. *
* *
***************************************************************************/
"""
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import QObject, QCoreApplication, QSettings, QLocale, QFileInfo, QTranslator, SIGNAL
from PyQt4.QtGui import QMessageBox, QMenu, QIcon, QAction
from qgis.core import QGis
import qgis.utils
# load icons for actions
import resources_rc
# are all dependencies satisfied?
valid = True
# Import required modules
req_mods = {"osgeo": "osgeo [python-gdal]"}
try:
from osgeo import gdal
from osgeo import ogr
except ImportError as e:
valid = False
# if the plugin is shipped with QGis catch the exception and
# display an error message
import os.path
qgisUserPluginPath = qgis.utils.home_plugin_path
if not os.path.dirname(__file__).startswith(qgisUserPluginPath):
title = QCoreApplication.translate("GdalTools", "Plugin error")
message = QCoreApplication.translate("GdalTools", u'Unable to load {0} plugin. \nThe required "{1}" module is missing. \nInstall it and try again.')
import qgis.utils
QMessageBox.warning(qgis.utils.iface.mainWindow(), title, message.format("GdalTools", req_mods["osgeo"]))
else:
# if a module is missing show a more friendly module's name
error_str = e.args[0]
error_mod = error_str.replace("No module named ", "")
if error_mod in req_mods:
error_str = error_str.replace(error_mod, req_mods[error_mod])
raise ImportError(error_str)
class GdalTools:
def __init__(self, iface):
if not valid:
return
# Save reference to the QGIS interface
self.iface = iface
try:
self.QgisVersion = unicode(QGis.QGIS_VERSION_INT)
except:
self.QgisVersion = unicode(QGis.qgisVersion)[0]
if QGis.QGIS_VERSION[0:3] < "1.5":
# For i18n support
userPluginPath = qgis.utils.home_plugin_path + "/GdalTools"
systemPluginPath = qgis.utils.sys_plugin_path + "/GdalTools"
overrideLocale = QSettings().value("locale/overrideFlag", False, type=bool)
if not overrideLocale:
localeFullName = QLocale.system().name()
else:
localeFullName = QSettings().value("locale/userLocale", "", type=str)
if QFileInfo(userPluginPath).exists():
translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
else:
translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
self.localePath = translationPath
if QFileInfo(self.localePath).exists():
self.translator = QTranslator()
self.translator.load(self.localePath)
QCoreApplication.installTranslator(self.translator)
# The list of actions added to menus, so we can remove them when unloading the plugin
self._menuActions = []
def initGui(self):
if not valid:
return
if int(self.QgisVersion) < 1:
QMessageBox.warning(
self.iface.getMainWindow(), "Gdal Tools",
QCoreApplication.translate("GdalTools", "QGIS version detected: ") + unicode(self.QgisVersion) + ".xx\n"
+ QCoreApplication.translate("GdalTools", "This version of Gdal Tools requires at least QGIS version 1.0.0\nPlugin will not be enabled."))
return None
from tools.GdalTools_utils import GdalConfig, LayerRegistry
self.GdalVersionNum = GdalConfig.versionNum()
LayerRegistry.setIface(self.iface)
# find the Raster menu
rasterMenu = None
menu_bar = self.iface.mainWindow().menuBar()
actions = menu_bar.actions()
rasterText = QCoreApplication.translate("QgisApp", "&Raster")
for a in actions:
if a.menu() is not None and a.menu().title() == rasterText:
rasterMenu = a.menu()
break
if rasterMenu is None:
# no Raster menu, create and insert it before the Help menu
self.menu = QMenu(rasterText, self.iface.mainWindow())
lastAction = actions[len(actions) - 1]
menu_bar.insertMenu(lastAction, self.menu)
else:
self.menu = rasterMenu
self._menuActions.append(self.menu.addSeparator())
# projections menu (Warp (Reproject), Assign projection)
self.projectionsMenu = QMenu(QCoreApplication.translate("GdalTools", "Projections"), self.iface.mainWindow())
self.projectionsMenu.setObjectName("projectionsMenu")
self.warp = QAction(QIcon(":/icons/warp.png"), QCoreApplication.translate("GdalTools", "Warp (Reproject)..."), self.iface.mainWindow())
self.warp.setObjectName("warp")
self.warp.setStatusTip(QCoreApplication.translate("GdalTools", "Warp an image into a new coordinate system"))
QObject.connect(self.warp, SIGNAL("triggered()"), self.doWarp)
self.projection = QAction(QIcon(":icons/projection-add.png"), QCoreApplication.translate("GdalTools", "Assign Projection..."), self.iface.mainWindow())
self.projection.setObjectName("projection")
self.projection.setStatusTip(QCoreApplication.translate("GdalTools", "Add projection info to the raster"))
QObject.connect(self.projection, SIGNAL("triggered()"), self.doProjection)
self.extractProj = QAction(QIcon(":icons/projection-export.png"), QCoreApplication.translate("GdalTools", "Extract Projection..."), self.iface.mainWindow())
self.extractProj.setObjectName("extractProj")
self.extractProj.setStatusTip(QCoreApplication.translate("GdalTools", "Extract projection information from raster(s)"))
QObject.connect(self.extractProj, SIGNAL("triggered()"), self.doExtractProj)
self.projectionsMenu.addActions([self.warp, self.projection, self.extractProj])
# conversion menu (Rasterize (Vector to raster), Polygonize (Raster to vector), Translate, RGB to PCT, PCT to RGB)
self.conversionMenu = QMenu(QCoreApplication.translate("GdalTools", "Conversion"), self.iface.mainWindow())
self.conversionMenu.setObjectName("conversionMenu")
if self.GdalVersionNum >= 1300:
self.rasterize = QAction(QIcon(":/icons/rasterize.png"), QCoreApplication.translate("GdalTools", "Rasterize (Vector to Raster)..."), self.iface.mainWindow())
self.rasterize.setObjectName("rasterize")
self.rasterize.setStatusTip(QCoreApplication.translate("GdalTools", "Burns vector geometries into a raster"))
QObject.connect(self.rasterize, SIGNAL("triggered()"), self.doRasterize)
self.conversionMenu.addAction(self.rasterize)
if self.GdalVersionNum >= 1600:
self.polygonize = QAction(QIcon(":/icons/polygonize.png"), QCoreApplication.translate("GdalTools", "Polygonize (Raster to Vector)..."), self.iface.mainWindow())
self.polygonize.setObjectName("polygonize")
self.polygonize.setStatusTip(QCoreApplication.translate("GdalTools", "Produces a polygon feature layer from a raster"))
QObject.connect(self.polygonize, SIGNAL("triggered()"), self.doPolygonize)
self.conversionMenu.addAction(self.polygonize)
self.translate = QAction(QIcon(":/icons/translate.png"), QCoreApplication.translate("GdalTools", "Translate (Convert Format)..."), self.iface.mainWindow())
self.translate.setObjectName("translate")
self.translate.setStatusTip(QCoreApplication.translate("GdalTools", "Converts raster data between different formats"))
QObject.connect(self.translate, SIGNAL("triggered()"), self.doTranslate)
self.paletted = QAction(QIcon(":icons/24-to-8-bits.png"), QCoreApplication.translate("GdalTools", "RGB to PCT..."), self.iface.mainWindow())
self.paletted.setObjectName("paletted")
self.paletted.setStatusTip(QCoreApplication.translate("GdalTools", "Convert a 24bit RGB image to 8bit paletted"))
QObject.connect(self.paletted, SIGNAL("triggered()"), self.doPaletted)
self.rgb = QAction(QIcon(":icons/8-to-24-bits.png"), QCoreApplication.translate("GdalTools", "PCT to RGB..."), self.iface.mainWindow())
self.rgb.setObjectName("rgb")
self.rgb.setStatusTip(QCoreApplication.translate("GdalTools", "Convert an 8bit paletted image to 24bit RGB"))
QObject.connect(self.rgb, SIGNAL("triggered()"), self.doRGB)
self.conversionMenu.addActions([self.translate, self.paletted, self.rgb])
# extraction menu (Clipper, Contour)
self.extractionMenu = QMenu(QCoreApplication.translate("GdalTools", "Extraction"), self.iface.mainWindow())
self.extractionMenu.setObjectName("extractionMenu")
if self.GdalVersionNum >= 1600:
self.contour = QAction(QIcon(":/icons/contour.png"), QCoreApplication.translate("GdalTools", "Contour..."), self.iface.mainWindow())
self.contour.setObjectName("contour")
self.contour.setStatusTip(QCoreApplication.translate("GdalTools", "Builds vector contour lines from a DEM"))
QObject.connect(self.contour, SIGNAL("triggered()"), self.doContour)
self.extractionMenu.addAction(self.contour)
self.clipper = QAction(QIcon(":icons/raster-clip.png"), QCoreApplication.translate("GdalTools", "Clipper..."), self.iface.mainWindow())
self.clipper.setObjectName("clipper")
#self.clipper.setStatusTip( QCoreApplication.translate( "GdalTools", "Converts raster data between different formats") )
QObject.connect(self.clipper, SIGNAL("triggered()"), self.doClipper)
self.extractionMenu.addActions([self.clipper])
# analysis menu (DEM (Terrain model), Grid (Interpolation), Near black, Proximity (Raster distance), Sieve)
self.analysisMenu = QMenu(QCoreApplication.translate("GdalTools", "Analysis"), self.iface.mainWindow())
self.analysisMenu.setObjectName("analysisMenu")
if self.GdalVersionNum >= 1600:
self.sieve = QAction(QIcon(":/icons/sieve.png"), QCoreApplication.translate("GdalTools", "Sieve..."), self.iface.mainWindow())
self.sieve.setObjectName("sieve")
self.sieve.setStatusTip(QCoreApplication.translate("GdalTools", "Removes small raster polygons"))
QObject.connect(self.sieve, SIGNAL("triggered()"), self.doSieve)
self.analysisMenu.addAction(self.sieve)
if self.GdalVersionNum >= 1500:
self.nearBlack = QAction(QIcon(":/icons/nearblack.png"), QCoreApplication.translate("GdalTools", "Near Black..."), self.iface.mainWindow())
self.nearBlack.setObjectName("nearBlack")
self.nearBlack.setStatusTip(QCoreApplication.translate("GdalTools", "Convert nearly black/white borders to exact value"))
QObject.connect(self.nearBlack, SIGNAL("triggered()"), self.doNearBlack)
self.analysisMenu.addAction(self.nearBlack)
if self.GdalVersionNum >= 1700:
self.fillNodata = QAction(QIcon(":/icons/fillnodata.png"), QCoreApplication.translate("GdalTools", "Fill nodata..."), self.iface.mainWindow())
self.fillNodata.setObjectName("fillNodata")
self.fillNodata.setStatusTip(QCoreApplication.translate("GdalTools", "Fill raster regions by interpolation from edges"))
QObject.connect(self.fillNodata, SIGNAL("triggered()"), self.doFillNodata)
self.analysisMenu.addAction(self.fillNodata)
if self.GdalVersionNum >= 1600:
self.proximity = QAction(QIcon(":/icons/proximity.png"), QCoreApplication.translate("GdalTools", "Proximity (Raster Distance)..."), self.iface.mainWindow())
self.proximity.setObjectName("proximity")
self.proximity.setStatusTip(QCoreApplication.translate("GdalTools", "Produces a raster proximity map"))
QObject.connect(self.proximity, SIGNAL("triggered()"), self.doProximity)
self.analysisMenu.addAction(self.proximity)
if self.GdalVersionNum >= 1500:
self.grid = QAction(QIcon(":/icons/grid.png"), QCoreApplication.translate("GdalTools", "Grid (Interpolation)..."), self.iface.mainWindow())
self.grid.setObjectName("grid")
self.grid.setStatusTip(QCoreApplication.translate("GdalTools", "Create raster from the scattered data"))
QObject.connect(self.grid, SIGNAL("triggered()"), self.doGrid)
self.analysisMenu.addAction(self.grid)
if self.GdalVersionNum >= 1700:
self.dem = QAction(QIcon(":icons/dem.png"), QCoreApplication.translate("GdalTools", "DEM (Terrain Models)..."), self.iface.mainWindow())
self.dem.setObjectName("dem")
self.dem.setStatusTip(QCoreApplication.translate("GdalTools", "Tool to analyze and visualize DEMs"))
QObject.connect(self.dem, SIGNAL("triggered()"), self.doDEM)
self.analysisMenu.addAction(self.dem)
#self.analysisMenu.addActions( [ ] )
# miscellaneous menu (Build overviews (Pyramids), Tile index, Information, Merge, Build Virtual Raster (Catalog))
self.miscellaneousMenu = QMenu(QCoreApplication.translate("GdalTools", "Miscellaneous"), self.iface.mainWindow())
self.miscellaneousMenu.setObjectName("miscellaneousMenu")
if self.GdalVersionNum >= 1600:
self.buildVRT = QAction(QIcon(":/icons/vrt.png"), QCoreApplication.translate("GdalTools", "Build Virtual Raster (Catalog)..."), self.iface.mainWindow())
self.buildVRT.setObjectName("buildVRT")
self.buildVRT.setStatusTip(QCoreApplication.translate("GdalTools", "Builds a VRT from a list of datasets"))
QObject.connect(self.buildVRT, SIGNAL("triggered()"), self.doBuildVRT)
self.miscellaneousMenu.addAction(self.buildVRT)
self.merge = QAction(QIcon(":/icons/merge.png"), QCoreApplication.translate("GdalTools", "Merge..."), self.iface.mainWindow())
self.merge.setObjectName("merge")
self.merge.setStatusTip(QCoreApplication.translate("GdalTools", "Build a quick mosaic from a set of images"))
QObject.connect(self.merge, SIGNAL("triggered()"), self.doMerge)
self.info = QAction(QIcon(":/icons/raster-info.png"), QCoreApplication.translate("GdalTools", "Information..."), self.iface.mainWindow())
self.info.setObjectName("info")
self.info.setStatusTip(QCoreApplication.translate("GdalTools", "Lists information about raster dataset"))
QObject.connect(self.info, SIGNAL("triggered()"), self.doInfo)
self.overview = QAction(QIcon(":icons/raster-overview.png"), QCoreApplication.translate("GdalTools", "Build Overviews (Pyramids)..."), self.iface.mainWindow())
self.overview.setObjectName("overview")
self.overview.setStatusTip(QCoreApplication.translate("GdalTools", "Builds or rebuilds overview images"))
QObject.connect(self.overview, SIGNAL("triggered()"), self.doOverview)
self.tileindex = QAction(QIcon(":icons/tiles.png"), QCoreApplication.translate("GdalTools", "Tile Index..."), self.iface.mainWindow())
self.tileindex.setObjectName("tileindex")
self.tileindex.setStatusTip(QCoreApplication.translate("GdalTools", "Build a shapefile as a raster tileindex"))
QObject.connect(self.tileindex, SIGNAL("triggered()"), self.doTileIndex)
self.miscellaneousMenu.addActions([self.merge, self.info, self.overview, self.tileindex])
self._menuActions.append(self.menu.addMenu(self.projectionsMenu))
self._menuActions.append(self.menu.addMenu(self.conversionMenu))
self._menuActions.append(self.menu.addMenu(self.extractionMenu))
if not self.analysisMenu.isEmpty():
self._menuActions.append(self.menu.addMenu(self.analysisMenu))
self._menuActions.append(self.menu.addMenu(self.miscellaneousMenu))
self.settings = QAction(QCoreApplication.translate("GdalTools", "GdalTools Settings..."), self.iface.mainWindow())
self.settings.setObjectName("settings")
self.settings.setStatusTip(QCoreApplication.translate("GdalTools", "Various settings for Gdal Tools"))
QObject.connect(self.settings, SIGNAL("triggered()"), self.doSettings)
self.menu.addAction(self.settings)
self._menuActions.append(self.settings)
def unload(self):
if not valid:
return
for a in self._menuActions:
self.menu.removeAction(a)
def doBuildVRT(self):
from tools.doBuildVRT import GdalToolsDialog as BuildVRT
d = BuildVRT(self.iface)
self.runToolDialog(d)
def doContour(self):
from tools.doContour import GdalToolsDialog as Contour
d = Contour(self.iface)
self.runToolDialog(d)
def doRasterize(self):
from tools.doRasterize import GdalToolsDialog as Rasterize
d = Rasterize(self.iface)
self.runToolDialog(d)
def doPolygonize(self):
from tools.doPolygonize import GdalToolsDialog as Polygonize
d = Polygonize(self.iface)
self.runToolDialog(d)
def doMerge(self):
from tools.doMerge import GdalToolsDialog as Merge
d = Merge(self.iface)
self.runToolDialog(d)
def doSieve(self):
from tools.doSieve import GdalToolsDialog as Sieve
d = Sieve(self.iface)
self.runToolDialog(d)
def doProximity(self):
from tools.doProximity import GdalToolsDialog as Proximity
d = Proximity(self.iface)
self.runToolDialog(d)
def doNearBlack(self):
from tools.doNearBlack import GdalToolsDialog as NearBlack
d = NearBlack(self.iface)
self.runToolDialog(d)
def doFillNodata(self):
from tools.doFillNodata import GdalToolsDialog as FillNodata
d = FillNodata(self.iface)
self.runToolDialog(d)
def doWarp(self):
from tools.doWarp import GdalToolsDialog as Warp
d = Warp(self.iface)
self.runToolDialog(d)
def doGrid(self):
from tools.doGrid import GdalToolsDialog as Grid
d = Grid(self.iface)
self.runToolDialog(d)
def doTranslate(self):
from tools.doTranslate import GdalToolsDialog as Translate
d = Translate(self.iface)
self.runToolDialog(d)
def doInfo(self):
from tools.doInfo import GdalToolsDialog as Info
d = Info(self.iface)
self.runToolDialog(d)
def doProjection(self):
from tools.doProjection import GdalToolsDialog as Projection
d = Projection(self.iface)
self.runToolDialog(d)
def doOverview(self):
from tools.doOverview import GdalToolsDialog as Overview
d = Overview(self.iface)
self.runToolDialog(d)
def doClipper(self):
from tools.doClipper import GdalToolsDialog as Clipper
d = Clipper(self.iface)
self.runToolDialog(d)
def doPaletted(self):
from tools.doRgbPct import GdalToolsDialog as RgbPct
d = RgbPct(self.iface)
self.runToolDialog(d)
def doRGB(self):
from tools.doPctRgb import GdalToolsDialog as PctRgb
d = PctRgb(self.iface)
self.runToolDialog(d)
def doTileIndex(self):
from tools.doTileIndex import GdalToolsDialog as TileIndex
d = TileIndex(self.iface)
self.runToolDialog(d)
def doExtractProj(self):
from tools.doExtractProj import GdalToolsDialog as ExtractProj
d = ExtractProj(self.iface)
d.exec_()
def doDEM(self):
from tools.doDEM import GdalToolsDialog as DEM
d = DEM(self.iface)
self.runToolDialog(d)
def runToolDialog(self, dlg):
dlg.show_()
dlg.exec_()
del dlg
def doSettings(self):
from tools.doSettings import GdalToolsSettingsDialog as Settings
d = Settings(self.iface)
d.exec_()

View File

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

View File

@ -1,25 +0,0 @@
"""
/***************************************************************************
Name : GdalTools
Description : Integrate gdal tools into qgis
Date : 17/Sep/09
copyright : (C) 2009 by Lorenzo Masini and Giuseppe Sucameli (Faunalia)
email : lorenxo86@gmail.com - brush.tyler@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. *
* *
***************************************************************************/
This script initializes the plugin, making it known to QGIS.
"""
def classFactory(iface):
# load GdalTools class from file GdalTools
from GdalTools import GdalTools
return GdalTools(iface)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 B

View File

@ -1,2 +0,0 @@
FILE(GLOB ICON_FILES *.png)
PLUGIN_INSTALL(GdalTools icons ${ICON_FILES})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,13 +0,0 @@
[general]
name=GdalTools
description=Integrate GDAL tools into QGIS
category=Raster
version=1.2.29
qgisMinimumVersion=2.0
author=Giuseppe Sucameli (Faunalia)
email=brush.tyler@gmail.com
icon=icons/raster-info.png
class_name=GdalTools

View File

@ -1,30 +0,0 @@
<RCC>
<qresource prefix="/">
<file>icons/contour.png</file>
<file>icons/merge.png</file>
<file>icons/polygonize.png</file>
<file>icons/rasterize.png</file>
<file>icons/sieve.png</file>
<file>icons/vrt.png</file>
<file>icons/warp.png</file>
<file>icons/proximity.png</file>
<file>icons/nearblack.png</file>
<file>icons/grid.png</file>
<file>icons/translate.png</file>
<file>icons/raster-info.png</file>
<file>icons/projection-add.png</file>
<file>icons/raster-overview.png</file>
<file>icons/raster-clip.png</file>
<file>icons/raster-rgb.png</file>
<file>icons/tiles.png</file>
<file>icons/about.png</file>
<file>icons/dem.png</file>
<file>icons/projection-export.png</file>
<file>icons/fillnodata.png</file>
<file>icons/24-to-8-bits.png</file>
<file>icons/8-to-24-bits.png</file>
<file>icons/edit.png</file>
<file>icons/reset.png</file>
<file>icons/tooltip.png</file>
</qresource>
</RCC>

View File

@ -1,8 +0,0 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB UI_FILES *.ui)
FILE(GLOB COLOR_CONFIG_FILES terrain.txt)
PYQT_WRAP_UI(PYUI_FILES ${UI_FILES})
PLUGIN_INSTALL(GdalTools tools ${PY_FILES} ${PYUI_FILES} ${COLOR_CONFIG_FILES})

View File

@ -1,961 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
GdalTools_utils.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
# Utility functions
# -------------------------------------------------
# getLastUsedDir()
# setLastUsedDir( QString *file_or_dir path )
# -------------------------------------------------
from PyQt4.QtCore import QObject, QSettings, QFileInfo, SIGNAL, QDir, QCoreApplication
from PyQt4.QtGui import QFileDialog
from qgis.core import QgsApplication, QgsMapLayerRegistry, QgsRectangle, QgsProviderRegistry, QgsLogger
from qgis.gui import QgsEncodingFileDialog
from osgeo import gdal, ogr, osr
import os
# to know the os
import platform
import sys
import string
import re
# Escapes arguments and return them joined in a string
def escapeAndJoin(strList):
joined = ''
for s in strList:
if s.find(" ") is not -1:
escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') + '"'
else:
escaped = s
joined += escaped + " "
return joined.strip()
# Retrieves last used dir from persistent settings
def getLastUsedDir():
settings = QSettings()
lastProjectDir = settings.value("/UI/lastProjectDir", u".", type=unicode)
return settings.value("/GdalTools/lastUsedDir", lastProjectDir, type=unicode)
# Stores last used dir in persistent settings
def setLastUsedDir(filePath):
settings = QSettings()
fileInfo = QFileInfo(filePath)
if fileInfo.isDir():
dirPath = fileInfo.filePath()
else:
dirPath = fileInfo.path()
settings.setValue("/GdalTools/lastUsedDir", dirPath)
# Retrieves GDAL binaries location
def getGdalBinPath():
settings = QSettings()
return settings.value("/GdalTools/gdalPath", u"", type=unicode)
# Stores GDAL binaries location
def setGdalBinPath(path):
settings = QSettings()
settings.setValue("/GdalTools/gdalPath", path)
# Retrieves GDAL python modules location
def getGdalPymodPath():
settings = QSettings()
return settings.value("/GdalTools/gdalPymodPath", u"", type=unicode)
# Stores GDAL python modules location
def setGdalPymodPath(path):
settings = QSettings()
settings.setValue("/GdalTools/gdalPymodPath", path)
# Retrieves GDAL help files location
def getHelpPath():
settings = QSettings()
return settings.value("/GdalTools/helpPath", u"", type=unicode)
# Stores GDAL help files location
def setHelpPath(path):
settings = QSettings()
settings.setValue("/GdalTools/helpPath", path)
# Retrieves last used encoding from persistent settings
def getLastUsedEncoding():
settings = QSettings()
return settings.value("/UI/encoding", u"System", type=unicode)
# Stores last used encoding in persistent settings
def setLastUsedEncoding(encoding):
settings = QSettings()
settings.setValue("/UI/encoding", encoding)
def getRasterExtensions():
formats = FileFilter.allRastersFilter().split(";;")
extensions = []
for f in formats:
if string.find(f, "*.bt") is not -1 or string.find(f, "*.mpr") is not -1: # Binary Terrain or ILWIS
continue
extensions.extend(FileFilter.getFilterExtensions(f))
return extensions
def getVectorExtensions():
formats = FileFilter.allVectorsFilter().split(";;")
extensions = []
for f in formats:
extensions.extend(FileFilter.getFilterExtensions(f))
return extensions
class LayerRegistry(QObject):
_instance = None
_iface = None
@staticmethod
def instance():
if LayerRegistry._instance is None:
LayerRegistry._instance = LayerRegistry()
return LayerRegistry._instance
@staticmethod
def setIface(iface):
LayerRegistry._iface = iface
layers = []
def __init__(self):
QObject.__init__(self)
if LayerRegistry._instance is not None:
return
LayerRegistry.layers = self.getAllLayers()
LayerRegistry._instance = self
self.connect(QgsMapLayerRegistry.instance(), SIGNAL("removeAll()"), self.removeAllLayers)
self.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWasAdded(QgsMapLayer *)"), self.layerAdded)
self.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWillBeRemoved(QString)"), self.removeLayer)
def getAllLayers(self):
if LayerRegistry._iface and hasattr(LayerRegistry._iface, 'legendInterface'):
return LayerRegistry._iface.legendInterface().layers()
return QgsMapLayerRegistry.instance().mapLayers().values()
def layerAdded(self, layer):
LayerRegistry.layers.append(layer)
self.emit(SIGNAL("layersChanged"))
def removeLayer(self, layerId):
LayerRegistry.layers = filter(lambda x: x.id() != layerId, LayerRegistry.layers)
self.emit(SIGNAL("layersChanged"))
def removeAllLayers(self):
LayerRegistry.layers = []
self.emit(SIGNAL("layersChanged"))
@classmethod
def isRaster(self, layer):
# only gdal raster layers
if layer.type() != layer.RasterLayer:
return False
if layer.providerType() != 'gdal':
return False
return True
def getRasterLayers(self):
return filter(self.isRaster, LayerRegistry.layers)
@classmethod
def isVector(self, layer):
if layer.type() != layer.VectorLayer:
return False
if layer.providerType() != 'ogr':
return False
return True
def getVectorLayers(self):
return filter(self.isVector, LayerRegistry.layers)
def getRasterFiles(path, recursive=False):
rasters = []
if not QFileInfo(path).exists():
return rasters
# TODO remove *.aux.xml
_filter = getRasterExtensions()
workDir = QDir(path)
workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
workDir.setNameFilters(_filter)
files = workDir.entryList()
for f in files:
rasters.append(path + "/" + f)
if recursive:
for myRoot, myDirs, myFiles in os.walk(unicode(path)):
for dir in myDirs:
workDir = QDir(myRoot + "/" + dir)
workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
workDir.setNameFilters(_filter)
workFiles = workDir.entryList()
for f in workFiles:
rasters.append(myRoot + "/" + dir + "/" + f)
return rasters
def fillRasterOutputFormat(aFilter=None, filename=None):
shortName = ''
if aFilter is not None:
supportedRasters = GdalConfig.getSupportedRasters()
filterName = re.sub('^.*\] ', '', FileFilter.getFilterName(aFilter))
if filterName is supportedRasters:
return supportedRasters[filterName]["SHORTNAME"]
shortName = GdalConfig.SupportedRasters.long2ShortName(filterName)
if shortName == '' and filename is not None:
shortName = GdalConfig.SupportedRasters.filename2ShortName(filename)
if shortName == '':
shortName = "GTiff"
return shortName
def fillVectorOutputFormat(aFilter=None, filename=None):
shortName = ''
if aFilter is not None:
supportedVectors = GdalConfig.getSupportedVectors()
filterName = re.sub('^.*\] ', '', FileFilter.getFilterName(aFilter))
if filterName in supportedVectors:
return supportedVectors[filterName]["SHORTNAME"]
pass # shortName = GdalConfig.SupportedVectors.long2ShortName(filterName)
if shortName == '' and filename is not None:
pass # shortName = GdalConfig.SupportedVectors.filename2ShortName(filename)
if shortName == '':
shortName = "ESRI Shapefile"
return shortName
class UnsupportedOGRFormat(Exception):
def __init__(self):
msg = QCoreApplication.translate("GdalTools", "The selected file is not a supported OGR format")
Exception.__init__(self, msg)
def getVectorFields(vectorFile):
hds = ogr.Open(unicode(vectorFile).encode('utf8'))
if hds is None:
raise UnsupportedOGRFormat()
fields = []
names = []
layer = hds.GetLayer(0)
defn = layer.GetLayerDefn()
for i in range(defn.GetFieldCount()):
fieldDefn = defn.GetFieldDefn(i)
fieldType = fieldDefn.GetType()
if fieldType == 0 or fieldType == 2:
fields.append(fieldDefn)
names.append(fieldDefn.GetName())
return (fields, names)
# get raster SRS if possible
def getRasterSRS(parent, fileName):
ds = gdal.Open(fileName)
if ds is None:
return ''
proj = ds.GetProjectionRef()
if proj is None:
return ''
sr = osr.SpatialReference()
if sr.ImportFromWkt(proj) != gdal.CE_None:
return ''
name = sr.GetAuthorityName(None)
code = sr.GetAuthorityCode(None)
if name is not None and code is not None:
return '%s:%s' % (name, code)
return ''
# get raster extent using python API - replaces old method which parsed gdalinfo output
def getRasterExtent(parent, fileName):
ds = gdal.Open(fileName)
if ds is None:
return
x = ds.RasterXSize
y = ds.RasterYSize
gt = ds.GetGeoTransform()
if gt is None:
xUL = 0
yUL = 0
xLR = x
yLR = y
else:
xUL = gt[0]
yUL = gt[3]
xLR = gt[0] + gt[1] * x + gt[2] * y
yLR = gt[3] + gt[4] * x + gt[5] * y
return QgsRectangle(xUL, yLR, xLR, yUL)
# get raster resolution
def getRasterResolution(fileName):
ds = gdal.Open(fileName)
if ds is None:
return
gt = ds.GetGeoTransform()
if gt is None:
return
else:
xRes = abs(gt[1])
yRes = abs(gt[5])
return (xRes, yRes)
# This class is used to replace the QFileDialog class.
# Its static methods are used in place of the respective QFileDialog ones to:
# 1. set the last used directory
# 2. append the selected extension to the file name
# 3. bypass the following bug:
# when you use the 'filter' argument, the dialog is enlarged up to the longest filter length,
# so sometimes the dialog excedes the screen width
class FileDialog:
@classmethod
def getDialog(self, parent=None, caption='', acceptMode=QFileDialog.AcceptOpen, fileMode=QFileDialog.ExistingFile, filter='', selectedFilter=None, useEncoding=False):
if useEncoding:
dialog = QgsEncodingFileDialog(parent, caption, getLastUsedDir(), filter, getLastUsedEncoding())
else:
dialog = QFileDialog(parent, caption, getLastUsedDir(), filter)
dialog.setFileMode(fileMode)
dialog.setAcceptMode(acceptMode)
if selectedFilter is not None:
dialog.selectNameFilter(selectedFilter[0])
if not dialog.exec_():
if useEncoding:
return ('', None)
return ''
# change the selected filter value
if selectedFilter is not None:
selectedFilter[0] = dialog.selectedNameFilter()
# save the last used dir and return the selected files
files = dialog.selectedFiles()
if files != '':
setLastUsedDir(files[0])
if fileMode != QFileDialog.ExistingFiles:
files = files[0]
# append the extension if not already present
if fileMode == QFileDialog.AnyFile:
firstExt = None
for ext in FileFilter.getFilterExtensions(dialog.selectedNameFilter()):
if FileFilter.filenameMatchesFilterExt(files, ext):
firstExt = None
break
if firstExt is None:
firstExt = ext
if firstExt is not None:
if firstExt.startswith('*'):
files += firstExt[1:]
if useEncoding:
encoding = dialog.encoding()
# encoding setted yet by QgsEncodingFileDialog
#setLastUsedEncoding(encoding)
return (files, encoding)
return files
@classmethod
def getOpenFileNames(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFiles, filter, selectedFilter, useEncoding)
@classmethod
def getOpenFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFile, filter, selectedFilter, useEncoding)
@classmethod
def getSaveFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptSave, QFileDialog.AnyFile, filter, selectedFilter, useEncoding)
@classmethod
def getExistingDirectory(self, parent=None, caption='', useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.DirectoryOnly, '', None, useEncoding)
class FileFilter:
@classmethod
def getFilter(self, typeName):
settings = QSettings()
return settings.value("/GdalTools/" + typeName + "FileFilter", u"", type=unicode)
@classmethod
def setFilter(self, typeName, aFilter):
settings = QSettings()
settings.setValue("/GdalTools/" + typeName + "FileFilter", aFilter)
# stores the supported raster file filter
rastersFilter = ''
# Retrieves the filter for supported raster files
@classmethod
def allRastersFilter(self):
if self.rastersFilter == '':
self.rastersFilter = QgsProviderRegistry.instance().fileRasterFilters()
# workaround for QGis < 1.5 (see #2376)
# removed as this is a core plugin QGis >= 1.9
return self.rastersFilter
# Retrieves the filter for supported raster files to save
# Skip *, *.zip and *.vrt and move tif to top
# TODO: only the formats with GDAL_DCAP_CREATE
@classmethod
def saveRastersFilter(self):
# move tif to top if available
available = self.allRastersFilter().split(";;")
filters = []
for f in available:
if "*.tif" in f:
filters.append(f)
break
for f in available:
if "*.tif" in f or "*.zip" in f or "(*)" in f:
continue
filters.append(f)
return ";;".join(filters)
# Retrieves the last used filter for raster files
# Note: filter string is in a list
@classmethod
def lastUsedRasterFilter(self):
return [self.getFilter("lastRaster")]
@classmethod
def setLastUsedRasterFilter(self, aFilter):
self.setFilter("lastRaster", aFilter[0])
# stores the supported vectors file filter
vectorsFilter = ''
# Retrieves the filter for supported vector files
@classmethod
def allVectorsFilter(self):
if self.vectorsFilter == '':
self.vectorsFilter = QgsProviderRegistry.instance().fileVectorFilters()
return self.vectorsFilter
# Retrieves the last used filter for vector files
# Note: filter string is in a list
@classmethod
def lastUsedVectorFilter(self):
return [self.getFilter("lastVector")]
@classmethod
def setLastUsedVectorFilter(self, aFilter):
self.setFilter("lastVector", aFilter[0])
# Retrieves the extensions list from a filter string
@classmethod
def getFilterExtensions(self, aFilter):
extList = []
# foreach format in filter string
for f in aFilter.split(";;"):
# gets the list of extensions from the filter
exts = re.sub('\).*$', '', re.sub('^.*\(', '', f))
# if there is no extensions or the filter matches all, then return an empty list
# otherwise return the list of estensions
if exts != '' and exts != "*" and exts != "*.*":
extList.extend(exts.split(" "))
return extList
@classmethod
def getFilterName(self, aFilter):
if isinstance(aFilter, list):
if len(aFilter):
aFilter = aFilter[0]
else:
aFilter = ""
return string.strip(re.sub('\ \(.*$', '', aFilter))
@classmethod
def filenameMatchesFilterExt(self, fileName, ext):
return re.match('.' + unicode(ext), fileName) is not None
# Retrieves gdal information
class GdalConfig:
# retrieves and return the installed gdal version
@classmethod
def version(self):
return Version(gdal.VersionInfo("RELEASE_NAME"))
@classmethod
def versionNum(self):
return int(gdal.VersionInfo("VERSION_NUM"))
# store the supported rasters info
supportedRasters = None
# retrieve the supported rasters info
@classmethod
def getSupportedRasters(self):
if self.supportedRasters is not None:
return self.supportedRasters
# first get the GDAL driver manager
if gdal.GetDriverCount() == 0:
gdal.AllRegister()
self.supportedRasters = dict()
jp2Driver = None
# for each loaded GDAL driver
for i in range(gdal.GetDriverCount()):
driver = gdal.GetDriver(i)
if driver is None:
QgsLogger.warning("unable to get driver " + unicode(i))
continue
# now we need to see if the driver is for something currently
# supported; if not, we give it a miss for the next driver
longName = string.strip(re.sub('\(.*$', '', driver.LongName))
shortName = string.strip(re.sub('\(.*$', '', driver.ShortName))
extensions = ''
description = driver.GetDescription()
glob = []
metadata = driver.GetMetadata()
if gdal.DMD_EXTENSION in metadata:
extensions = unicode(metadata[gdal.DMD_EXTENSION])
if longName != '':
if extensions != '':
# XXX add check for SDTS; in that case we want (*CATD.DDF)
#TODO fix and test
#glob.append( QString("*." + extensions.replace("/", " *.")).split(" "))
glob.append(string.split("*." + string.replace(extensions, "/", " *."), sep=(" ")))
# Add only the first JP2 driver found to the filter list (it's the one GDAL uses)
if description == "JPEG2000" or description.startswith("JP2"): # JP2ECW, JP2KAK, JP2MrSID
if jp2Driver is not None:
continue # skip if already found a JP2 driver
jp2Driver = driver # first JP2 driver found
glob.append("*.j2k") # add alternate extension
elif description == "GTiff":
glob.append("*.tiff")
elif description == "JPEG":
glob.append("*.jpeg")
else:
# USGS DEMs use "*.dem"
if description.startswith("USGSDEM"):
glob.append("*.dem")
elif description.startswith("DTED"):
# DTED use "*.dt0"
glob.append("*.dt0")
elif description.startswith("MrSID"):
# MrSID use "*.sid"
glob.append("*.sid")
else:
continue
self.supportedRasters[longName] = {'EXTENSIONS': glob, 'LONGNAME': longName, 'SHORTNAME': shortName, 'DESCRIPTION': description}
return self.supportedRasters
# store the supported vectors info
supportedVectors = None
# retrieve the supported vectors info
@classmethod
def getSupportedVectors(self):
if self.supportedVectors is not None:
return self.supportedVectors
# first get the OGR driver manager
QgsApplication.registerOgrDrivers()
self.supportedVectors = dict()
# for each loaded OGR driver
for i in range(ogr.GetDriverCount()):
driver = ogr.GetDriver(i)
if driver is None:
QgsLogger.warning("unable to get driver " + unicode(i))
continue
driverName = driver.GetName()
longName = ''
glob = []
if driverName.startswith("AVCBin"):
pass # myDirectoryDrivers += "Arc/Info Binary Coverage,AVCBin"
elif driverName.startswith("AVCE00"):
longName = "Arc/Info ASCII Coverage"
glob.append("*.e00")
elif driverName.startswith("BNA"):
longName = "Atlas BNA"
glob.append("*.bna")
elif driverName.startswith("CSV"):
longName = "Comma Separated Value"
glob.append("*.csv")
elif driverName.startswith("DODS"):
pass # myProtocolDrivers += "DODS/OPeNDAP,DODS"
elif driverName.startswith("PGeo"):
pass # myDatabaseDrivers += "ESRI Personal GeoDatabase,PGeo"
# on Windows add a pair to the dict for this driver
if platform.system() == "Windows":
longName = "ESRI Personal GeoDatabase"
glob.append("*.mdb")
elif driverName.startswith("SDE"):
pass # myDatabaseDrivers += "ESRI ArcSDE,SDE"
elif driverName.startswith("ESRI"):
longName = "ESRI Shapefiles"
glob.append("*.shp")
elif driverName.startswith("FMEObjects Gateway"):
longName = "FMEObjects Gateway"
glob.append("*.fdd")
elif driverName.startswith("GeoJSON"):
pass # myProtocolDrivers += "GeoJSON,GeoJSON"
longName = "GeoJSON"
glob.append("*.geojson")
elif driverName.startswith("GeoRSS"):
longName = "GeoRSS"
glob.append("*.xml")
elif driverName.startswith("GML"):
longName = "Geography Markup Language"
glob.append("*.gml")
elif driverName.startswith("GMT"):
longName = "GMT"
glob.append("*.gmt")
elif driverName.startswith("GPX"):
longName = "GPX"
glob.append("*.gpx")
elif driverName.startswith("GRASS"):
pass # myDirectoryDrivers += "Grass Vector,GRASS"
elif driverName.startswith("IDB"):
pass # myDatabaseDrivers += "Informix DataBlade,IDB"
elif driverName.startswith("Interlis 1"):
longName = "INTERLIS 1"
glob.append("*.itf")
glob.append("*.xml")
glob.append("*.ili")
elif driverName.startswith("Interlis 2"):
longName = "INTERLIS 2"
glob.append("*.itf")
glob.append("*.xml")
glob.append("*.ili")
elif driverName.startswith("INGRES"):
pass # myDatabaseDrivers += "INGRES,INGRES"
elif driverName.startswith("KML"):
longName = "KML"
glob.append("*.kml")
elif driverName.startswith("MapInfo File"):
longName = "Mapinfo File"
glob.append("*.mif")
glob.append("*.tab")
elif driverName.startswith("DGN"):
longName = "Microstation DGN"
glob.append("*.dgn")
elif driverName.startswith("MySQL"):
pass # myDatabaseDrivers += "MySQL,MySQL"
elif driverName.startswith("OCI"):
pass # myDatabaseDrivers += "Oracle Spatial,OCI"
elif driverName.startswith("ODBC"):
pass # myDatabaseDrivers += "ODBC,ODBC"
elif driverName.startswith("OGDI"):
pass # myDatabaseDrivers += "OGDI Vectors,OGDI"
elif driverName.startswith("PostgreSQL"):
pass # myDatabaseDrivers += "PostgreSQL,PostgreSQL"
elif driverName.startswith("S57"):
longName = "S-57 Base file"
glob.append("*.000")
elif driverName.startswith("SDTS"):
longName = "Spatial Data Transfer Standard"
glob.append("*catd.ddf")
elif driverName.startswith("SQLite"):
longName = "SQLite"
glob.append("*.sqlite")
elif driverName.startswith("UK .NTF"):
pass # myDirectoryDrivers += "UK. NTF,UK. NTF"
elif driverName.startswith("TIGER"):
pass # myDirectoryDrivers += "U.S. Census TIGER/Line,TIGER"
elif driverName.startswith("VRT"):
longName = "VRT - Virtual Datasource "
glob.append("*.vrt")
elif driverName.startswith("XPlane"):
longName = "X-Plane/Flighgear"
glob.append("apt.dat")
glob.append("nav.dat")
glob.append("fix.dat")
glob.append("awy.dat")
longName = string.strip(longName)
if longName == '':
continue
self.supportedVectors[longName] = {'EXTENSIONS': glob, 'LONGNAME': longName, 'SHORTNAME': driverName}
return self.supportedVectors
class SupportedRasters:
dict_long2shortName = dict()
# retrieve the raster format short name by long format name
@classmethod
def long2ShortName(self, longName):
if longName == '':
return ''
if longName in self.dict_long2shortName:
return self.dict_long2shortName[longName]
# first get the GDAL driver manager
if gdal.GetDriverCount() == 0:
gdal.AllRegister()
shortName = ''
# for each loaded GDAL driver
for i in range(gdal.GetDriverCount()):
driver = gdal.GetDriver(i)
if driver is None:
continue
# if this is the driver we searched for then return its short name
if FileFilter.getFilterName(driver.LongName) == longName:
shortName = FileFilter.getFilterName(driver.ShortName)
self.dict_long2shortName[longName] = shortName
break
return shortName
# retrieve the raster format short name by using the file name extension
@classmethod
def filename2ShortName(self, fileName):
if fileName == '':
return ''
shortName = ''
# for each raster format search for the file extension
formats = FileFilter.allRastersFilter().split(";;")
for f in formats:
for ext in FileFilter.getFilterExtensions(f):
if FileFilter.filenameMatchesFilterExt(fileName, ext):
longName = FileFilter.getFilterName(f)
shortName = self.long2ShortName(longName)
break
if not shortName == '':
break
return shortName
# class which allows creating version objects and compare them
class Version:
def __init__(self, ver):
self.vers = ('0', '0', '0')
if isinstance(ver, Version):
self.vers = ver.vers
elif isinstance(ver, tuple) or isinstance(ver, list):
self.vers = map(str, ver)
elif isinstance(ver, str):
self.vers = self.string2vers(ver)
@staticmethod
def string2vers(string):
vers = ['0', '0', '0']
nums = unicode(string).split(".")
if len(nums) > 0:
vers[0] = nums[0]
if len(nums) > 1:
vers[1] = nums[1]
if len(nums) > 2:
vers[2] = nums[2]
return (vers[0], vers[1], vers[2])
def __cmp__(self, other):
if not isinstance(other, Version):
other = Version(other)
if self.vers > other.vers:
return 1
if self.vers < other.vers:
return -1
return 0
def __str__(self):
return ".".join(self.vers)
def setProcessEnvironment(process):
envvar_list = {
"PATH": getGdalBinPath(),
"PYTHONPATH": getGdalPymodPath(),
"GDAL_FILENAME_IS_UTF8": "NO"
}
sep = os.pathsep
for name, val in envvar_list.iteritems():
if val is None or val == "":
continue
envval = os.getenv(name)
if envval is None or envval == "":
envval = unicode(val)
elif (platform.system() == "Windows" and val.lower() not in envval.lower().split( sep )) or \
(platform.system() != "Windows" and val not in envval.split(sep)):
envval += "%s%s" % (sep, unicode(val))
else:
envval = None
if envval is not None:
os.putenv(name, envval)
def setMacOSXDefaultEnvironment():
# fix bug #3170: many GDAL Tools don't work in OS X standalone
if platform.system() != "Darwin":
return
# QgsApplication.prefixPath() contains the path to qgis executable (i.e. .../Qgis.app/MacOS)
# get the path to Qgis application folder
qgis_app = u"%s/.." % QgsApplication.prefixPath()
qgis_app = QDir(qgis_app).absolutePath()
qgis_bin = u"%s/bin" % QgsApplication.prefixPath() # path to QGis bin folder
qgis_python = u"%s/Resources/python" % qgis_app # path to QGis python folder
# path to the GDAL framework within the Qgis application folder (QGis standalone only)
qgis_standalone_gdal_path = u"%s/Frameworks/GDAL.framework" % qgis_app
# path to the GDAL framework when installed as external framework
gdal_versionsplit = unicode(GdalConfig.version()).split('.')
gdal_base_path = u"/Library/Frameworks/GDAL.framework/Versions/%s.%s" % (gdal_versionsplit[0], gdal_versionsplit[1])
if os.path.exists(qgis_standalone_gdal_path): # qgis standalone
# GDAL executables are in the QGis bin folder
if getGdalBinPath() == '':
setGdalBinPath(qgis_bin)
# GDAL pymods are in the QGis python folder
if getGdalPymodPath() == '':
setGdalPymodPath(qgis_python)
# GDAL help is in the framework folder
if getHelpPath() == '':
setHelpPath(u"%s/Resources/doc" % qgis_standalone_gdal_path)
elif os.path.exists(gdal_base_path):
# all GDAL parts are in the GDAL framework folder
if getGdalBinPath() == '':
setGdalBinPath(u"%s/Programs" % gdal_base_path)
if getGdalPymodPath() == '':
setGdalPymodPath(u"%s/Python/%s.%s/site-packages" % (gdal_base_path, sys.version_info[0], sys.version_info[1]))
if getHelpPath() == '':
setHelpPath(u"%s/Resources/doc" % gdal_base_path)
# setup the MacOSX path to both GDAL executables and python modules
if platform.system() == "Darwin":
setMacOSXDefaultEnvironment()

View File

@ -1,149 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsAboutDialog</class>
<widget class="QDialog" name="GdalToolsAboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>434</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>About Gdal Tools</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>GDAL Tools</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblVersion">
<property name="text">
<string>Version x.x-xxxxxx</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnWeb">
<property name="text">
<string>Web</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>btnClose</sender>
<signal>clicked()</signal>
<receiver>GdalToolsAboutDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>276</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,231 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
dialogBase.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import Qt, SIGNAL, QProcess, QUrl, QIODevice, QCoreApplication
from PyQt4.QtGui import QDialog, QIcon, QDialogButtonBox, QMessageBox, QDesktopServices, QErrorMessage, QApplication
# to know the os
import platform
from ui_dialogBase import Ui_GdalToolsDialog as Ui_Dialog
import GdalTools_utils as Utils
#from .. import resources_rc
import string
class GdalToolsBaseDialog(QDialog, Ui_Dialog):
def __init__(self, parent, iface, pluginBase, pluginName, pluginCommand):
QDialog.__init__(self, parent)
self.setAttribute(Qt.WA_DeleteOnClose)
self.iface = iface
self.process = QProcess(self)
Utils.setProcessEnvironment(self.process)
self.connect(self.process, SIGNAL("error(QProcess::ProcessError)"), self.processError)
self.connect(self.process, SIGNAL("finished(int, QProcess::ExitStatus)"), self.processFinished)
self.setupUi(self)
self.arguments = []
self.editCmdBtn.setIcon(QIcon(":/icons/edit.png"))
self.connect(self.editCmdBtn, SIGNAL("toggled(bool)"), self.editCommand)
self.resetCmdBtn.setIcon(QIcon(":/icons/reset.png"))
self.connect(self.resetCmdBtn, SIGNAL("clicked()"), self.resetCommand)
self.editCommand(False)
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
self.connect(self.buttonBox, SIGNAL("helpRequested()"), self.help)
self.buttonBox.button(QDialogButtonBox.Ok).setDefault(True)
self.plugin = pluginBase
self.connect(self.plugin, SIGNAL("valuesChanged(PyQt_PyObject)"), self.refreshArgs)
self.pluginLayout.addWidget(self.plugin)
self.plugin.setFocus()
self.setWindowTitle(pluginName)
self.setPluginCommand(pluginCommand)
def setPluginCommand(self, cmd):
# on Windows replace the .py with .bat extension
if platform.system() == "Windows" and cmd[-3:] == ".py":
self.command = cmd[:-3] + ".bat"
else:
self.command = cmd
if cmd[-3:] == ".py":
self.helpFileName = cmd[:-3] + ".html"
else:
self.helpFileName = cmd + ".html"
def editCommand(self, enabled):
if not self.commandIsEnabled():
return
self.editCmdBtn.setChecked(enabled)
self.resetCmdBtn.setEnabled(enabled)
self.textEditCommand.setReadOnly(not enabled)
self.controlsWidget.setEnabled(not enabled)
self.emit(SIGNAL("refreshArgs()"))
def resetCommand(self):
if not self.commandIsEditable():
return
self.emit(SIGNAL("refreshArgs()"))
def commandIsEditable(self):
return self.commandIsEnabled() and self.editCmdBtn.isChecked()
def setCommandViewerEnabled(self, enable):
if not enable:
self.editCommand(False)
self.commandWidget.setEnabled(enable)
def commandIsEnabled(self):
return self.commandWidget.isEnabled()
def reject(self):
if self.process.state() != QProcess.NotRunning:
ret = QMessageBox.warning(self, self.tr("Warning"), self.tr("The command is still running. \nDo you want terminate it anyway?"), QMessageBox.Yes | QMessageBox.No)
if ret == QMessageBox.No:
return
self.disconnect(self.process, SIGNAL("error(QProcess::ProcessError)"), self.processError)
self.disconnect(self.process, SIGNAL("finished(int, QProcess::ExitStatus)"), self.processFinished)
self.emit(SIGNAL("closeClicked()"))
def accept(self):
self.emit(SIGNAL("okClicked()"))
def help(self):
self.emit(SIGNAL("helpClicked()"))
def processError(self, error):
self.emit(SIGNAL("processError(QProcess::ProcessError)"), error)
def processFinished(self, exitCode, status):
self.emit(SIGNAL("processFinished(int, QProcess::ExitStatus)"), exitCode, status)
# show the online tool documentation in the default browser
def onHelp(self):
helpPath = Utils.getHelpPath()
if helpPath == '':
url = QUrl("http://www.gdal.org/" + self.helpFileName)
else:
url = QUrl.fromLocalFile(helpPath + '/' + self.helpFileName)
QDesktopServices.openUrl(url)
# called when a value in the plugin widget interface changed
def refreshArgs(self, args):
self.arguments = [unicode(a) for a in args]
if not self.commandIsEnabled():
self.textEditCommand.setPlainText(self.command)
else:
self.textEditCommand.setPlainText(self.command + " " + Utils.escapeAndJoin(self.arguments))
# enables the OK button
def enableRun(self, enable=True):
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
# start the command execution
def onRun(self):
self.enableRun(False)
self.setCursor(Qt.WaitCursor)
if not self.commandIsEditable():
#print(self.command+' '+unicode(self.arguments))
self.process.start(self.command, self.arguments, QIODevice.ReadOnly)
else:
self.process.start(self.textEditCommand.toPlainText(), QIODevice.ReadOnly)
# stop the command execution
def stop(self):
self.enableRun(True)
self.setCursor(Qt.ArrowCursor)
self.process.kill()
# called on closing the dialog, stop the process if it's running
def onClosing(self):
self.stop()
QDialog.reject(self)
# called if an error occurs when the command has not already finished, shows the occurred error message
def onError(self, error):
if error == QProcess.FailedToStart:
msg = QCoreApplication.translate("GdalTools", "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.")
elif error == QProcess.Crashed:
msg = QCoreApplication.translate("GdalTools", "The process crashed some time after starting successfully.")
else:
msg = QCoreApplication.translate("GdalTools", "An unknown error occurred.")
QErrorMessage(self).showMessage(msg)
QApplication.processEvents() # give the user chance to see the message
self.stop()
# called when the command finished its execution, shows an error message if there's one
# and, if required, load the output file in canvas
def onFinished(self, exitCode, status):
if status == QProcess.CrashExit:
self.stop()
return
if self.command.find("gdalinfo") != -1 and exitCode == 0:
self.emit(SIGNAL("finished(bool)"), self.loadCheckBox.isChecked())
self.stop()
return
# show the error message if there's one, otherwise show the process output message
msg = unicode(self.process.readAllStandardError())
if msg == '':
outMessages = unicode(self.process.readAllStandardOutput()).splitlines()
# make sure to not show the help
for m in outMessages:
m = string.strip(m)
if m == '':
continue
# TODO fix this
#if m.contains( QRegExp( "^(?:[Uu]sage:\\s)?" + QRegExp.escape(self.command) + "\\s" ) ):
# if msg.isEmpty():
# msg = self.tr ( "Invalid parameters." )
# break
#if m.contains( QRegExp( "0(?:\\.+[1-9]0{1,2})+" ) ):
# continue
if msg:
msg += "\n"
msg += m
QErrorMessage(self).showMessage(msg.replace("\n", "<br>"))
if exitCode == 0:
self.emit(SIGNAL("finished(bool)"), self.loadCheckBox.isChecked())
self.stop()

View File

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsDialog</class>
<widget class="QDialog" name="GdalToolsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>179</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="controlsWidget" native="true">
<layout class="QVBoxLayout" name="pluginLayout">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="loadCheckBox">
<property name="text">
<string>&amp;Load into canvas when finished</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="commandWidget" native="true">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QPlainTextEdit" name="textEditCommand">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="editCmdBtn">
<property name="toolTip">
<string>Edit</string>
</property>
<property name="text">
<string>Edit</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="resetCmdBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Reset</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsDialog</class>
<widget class="QDialog" name="GdalToolsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>192</height>
</rect>
</property>
<property name="windowTitle">
<string>Extract projection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="batchCheck">
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item>
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="prjCheck">
<property name="text">
<string>Create also prj file</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GdalToolsDialog</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>GdalToolsDialog</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>

View File

@ -1,61 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
dialogSRS.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QDialog, QVBoxLayout, QDialogButtonBox
from qgis.gui import QgsProjectionSelector
class GdalToolsSRSDialog(QDialog):
def __init__(self, title, parent=None):
QDialog.__init__(self, parent)
self.setWindowTitle(title)
layout = QVBoxLayout()
self.selector = QgsProjectionSelector(self)
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close)
layout.addWidget(self.selector)
layout.addWidget(buttonBox)
self.setLayout(layout)
self.connect(buttonBox, SIGNAL("accepted()"), self.accept)
self.connect(buttonBox, SIGNAL("rejected()"), self.reject)
def authid(self):
return unicode(self.selector.selectedAuthId())
def proj4string(self):
return self.selector.selectedProj4String()
def getProjection(self):
if self.authid().upper().startswith("EPSG:"):
return self.authid()
if self.selector.selectedProj4String():
return self.proj4string()
return ''

View File

@ -1,240 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsSettingsDialog</class>
<widget class="QDialog" name="GdalToolsSettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>371</width>
<height>341</height>
</rect>
</property>
<property name="windowTitle">
<string>Gdal Tools settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Path to the GDAL executables</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="bin_tooltip_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">##tooltip icon##</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="leGdalBinPath"/>
</item>
<item>
<widget class="QPushButton" name="btnSetBinPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Path to the GDAL python modules</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="pymod_tooltip_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">##tooltip icon##</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="leGdalPymodPath"/>
</item>
<item>
<widget class="QPushButton" name="btnSetPymodPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>GDAL help path</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="help_tooltip_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">##tooltip icon##</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="leGdalHelpPath"/>
</item>
<item>
<widget class="QPushButton" name="btnSetHelpPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>GDAL data path</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="leGdalDataPath">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSetDataPath">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>GDAL driver path</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="leGdalDriverPath">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSetDriverPath">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GdalToolsSettingsDialog</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>GdalToolsSettingsDialog</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>

View File

@ -1,175 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doBuildVRT.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QCoreApplication, QObject
from PyQt4.QtGui import QWidget
from ui_widgetBuildVRT import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
from dialogSRS import GdalToolsSRSDialog as SRSDialog
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.resolutions = ("highest", "average", "lowest")
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdalbuildvrt")
self.inSelector.setType(self.inSelector.FILE)
self.outSelector.setType(self.outSelector.FILE)
self.recurseCheck.hide()
self.visibleRasterLayers = []
self.setParamsStatus(
[
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.resolutionComboBox, SIGNAL("currentIndexChanged(int)"), self.resolutionCheck),
(self.noDataEdit, SIGNAL("textChanged( const QString & )"), self.srcNoDataCheck, 1700),
(self.inputDirCheck, SIGNAL("stateChanged(int)")),
(self.separateCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.targetSRSEdit, SIGNAL("textChanged(const QString &)"), self.targetSRSCheck),
(self.allowProjDiffCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck),
(self.inputSelLayersCheck, SIGNAL("stateChanged(int)"))
]
)
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.inputDirCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
self.connect(self.inputSelLayersCheck, SIGNAL("stateChanged( int )"), self.switchLayerMode)
self.connect(self.iface.mapCanvas(), SIGNAL("stateChanged( int )"), self.switchLayerMode)
self.connect(self.selectTargetSRSButton, SIGNAL("clicked()"), self.fillTargetSRSEdit)
def initialize(self):
# connect to mapCanvas.layerChanged() signal
self.connect(self.iface.mapCanvas(), SIGNAL("layersChanged()"), self.onVisibleLayersChanged)
self.onVisibleLayersChanged()
BasePluginWidget.initialize(self)
def onClosing(self):
# disconnect from mapCanvas.layerChanged() signal
self.disconnect(self.iface.mapCanvas(), SIGNAL("layersChanged()"), self.onVisibleLayersChanged)
BasePluginWidget.onClosing(self)
def onVisibleLayersChanged(self):
# refresh list of visible raster layers
self.visibleRasterLayers = []
for layer in self.iface.mapCanvas().layers():
if Utils.LayerRegistry.isRaster(layer):
self.visibleRasterLayers.append(layer.source())
# refresh the text in the command viewer
self.someValueChanged()
def switchToolMode(self):
self.recurseCheck.setVisible(self.inputDirCheck.isChecked())
self.inSelector.clear()
if self.inputDirCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
else:
self.label.setText(self.inFileLabel)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
def switchLayerMode(self):
enableInputFiles = not self.inputSelLayersCheck.isChecked()
self.inputDirCheck.setEnabled(enableInputFiles)
self.inSelector.setEnabled(enableInputFiles)
self.recurseCheck.setEnabled(enableInputFiles)
def fillInputFilesEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
files = Utils.FileDialog.getOpenFileNames(self, self.tr("Select the files for VRT"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if files == '':
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(",".join(files))
def fillOutputFileEdit(self):
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the VRT"), self.tr("VRT (*.vrt)"))
if outputFile == '':
return
self.outSelector.setFilename(outputFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files for VRT"))
if inputDir == '':
return
self.inSelector.setFilename(inputDir)
def fillTargetSRSEdit(self):
dialog = SRSDialog("Select the target SRS", self)
if dialog.exec_():
self.targetSRSEdit.setText(dialog.getProjection())
def getArguments(self):
arguments = []
if self.resolutionCheck.isChecked() and self.resolutionComboBox.currentIndex() >= 0:
arguments.append("-resolution")
arguments.append(self.resolutions[self.resolutionComboBox.currentIndex()])
if self.separateCheck.isChecked():
arguments.append("-separate")
if self.srcNoDataCheck.isChecked():
nodata = self.noDataEdit.text().strip()
if nodata:
arguments.append("-srcnodata")
arguments.append(nodata)
if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text():
arguments.append("-a_srs")
arguments.append(self.targetSRSEdit.text())
if self.allowProjDiffCheck.isChecked():
arguments.append("-allow_projection_difference")
arguments.append(self.getOutputFileName())
if self.inputSelLayersCheck.isChecked():
arguments.extend(self.visibleRasterLayers)
elif self.inputDirCheck.isChecked():
arguments.extend(Utils.getRasterFiles(self.getInputFileName(), self.recurseCheck.isChecked()))
else:
arguments.extend(self.getInputFileName())
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
if self.inputDirCheck.isChecked():
return self.inSelector.filename()
return self.inSelector.filename().split(",")
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())

View File

@ -1,216 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doClipper.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget
from qgis.core import QGis
from ui_widgetClipper import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.canvas = self.iface.mapCanvas()
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_translate")
self.outSelector.setType(self.outSelector.FILE)
self.extentSelector.setCanvas(self.canvas)
self.outputFormat = Utils.fillRasterOutputFormat()
# set the default QDoubleSpinBoxes
self.xRes.setValue(12.5)
self.yRes.setValue(12.5)
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.noDataSpin, SIGNAL("valueChanged(int)"), self.noDataCheck, 1700),
(self.maskSelector, SIGNAL("filenameChanged()"), self.maskModeRadio, 1600),
(self.alphaBandCheck, SIGNAL("stateChanged(int)")),
(self.cropToCutlineCheck, SIGNAL("stateChanged(int)")),
([self.xRes, self.yRes], SIGNAL("valueChanged(double)"), self.setResolutionRadio),
(self.extentSelector, [SIGNAL("selectionStarted()"), SIGNAL("newExtentDefined()")], self.extentModeRadio),
(self.modeStackedWidget, SIGNAL("currentIndexChanged(int)"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.maskSelector, SIGNAL("selectClicked()"), self.fillMaskFileEdit)
self.connect(self.extentSelector, SIGNAL("newExtentDefined()"), self.extentChanged)
self.connect(self.extentSelector, SIGNAL("selectionStarted()"), self.checkRun)
self.connect(self.extentModeRadio, SIGNAL("toggled(bool)"), self.switchClippingMode)
self.connect(self.keepResolutionRadio, SIGNAL("toggled(bool)"), self.switchResolutionMode)
def show_(self):
self.switchClippingMode()
self.switchResolutionMode()
BasePluginWidget.show_(self)
def onClosing(self):
self.extentSelector.stop()
BasePluginWidget.onClosing(self)
def switchClippingMode(self):
if self.extentModeRadio.isChecked():
index = 0
self.extentSelector.start()
else:
self.extentSelector.stop()
index = 1
self.modeStackedWidget.setCurrentIndex(index)
self.checkRun()
def switchResolutionMode(self):
if self.keepResolutionRadio.isChecked():
self.resolutionWidget.hide()
else:
self.resolutionWidget.show()
def checkRun(self):
if self.extentModeRadio.isChecked():
enabler = self.extentSelector.isCoordsValid()
else:
enabler = not self.maskSelector.filename() == ''
self.base.enableRun(enabler)
def extentChanged(self):
self.activateWindow()
self.raise_()
self.checkRun()
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
self.maskSelector.setLayers(filter(lambda x: x.geometryType() == QGis.Polygon, Utils.LayerRegistry.instance().getVectorLayers()))
self.checkRun()
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Polygonize"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if inputFile == '':
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if outputFile == '':
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def fillMaskFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
maskFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the mask file"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter)
if maskFile == '':
return
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
self.maskSelector.setFilename(maskFile)
self.checkRun()
def getArguments(self):
if not self.extentModeRadio.isChecked():
return self.getArgsModeMask()
return self.getArgsModeExtent()
def getArgsModeExtent(self):
self.base.setPluginCommand("gdal_translate")
inputFn = self.getInputFileName()
arguments = []
if self.noDataCheck.isChecked():
arguments.append("-a_nodata")
arguments.append(unicode(self.noDataSpin.value()))
if self.extentModeRadio.isChecked() and self.extentSelector.isCoordsValid():
rect = self.extentSelector.getExtent()
if rect is not None and not inputFn == '':
arguments.append("-projwin")
arguments.append(unicode(rect.xMinimum()))
arguments.append(unicode(rect.yMaximum()))
arguments.append(unicode(rect.xMaximum()))
arguments.append(unicode(rect.yMinimum()))
outputFn = self.getOutputFileName()
if not outputFn == '':
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(inputFn)
arguments.append(outputFn)
return arguments
def getArgsModeMask(self):
self.base.setPluginCommand("gdalwarp")
inputFn = self.getInputFileName()
arguments = []
if self.noDataCheck.isChecked():
arguments.append("-dstnodata")
arguments.append(unicode(self.noDataSpin.value()))
if self.maskModeRadio.isChecked():
mask = self.maskSelector.filename()
if not mask == '' and not inputFn == '':
arguments.append("-q")
arguments.append("-cutline")
arguments.append(mask)
if Utils.GdalConfig.versionNum() >= 1800:
if self.cropToCutlineCheck.isChecked():
arguments.append("-crop_to_cutline")
if self.alphaBandCheck.isChecked():
arguments.append("-dstalpha")
if self.keepResolutionRadio.isChecked():
resolution = Utils.getRasterResolution(inputFn)
if resolution is not None:
arguments.append("-tr")
arguments.append(resolution[0])
arguments.append(resolution[1])
else:
arguments.append("-tr")
arguments.append(unicode(self.xRes.value()))
arguments.append(unicode(self.yRes.value()))
outputFn = self.getOutputFileName()
if not outputFn == '':
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(inputFn)
arguments.append(outputFn)
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
return self.inSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())

View File

@ -1,116 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doContour.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QDir
from PyQt4.QtGui import QWidget, QApplication
from ui_widgetContour import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_contour")
gdalVersion = Utils.GdalConfig.versionNum()
self.useDirAsOutput = gdalVersion < 1700
if self.useDirAsOutput:
self.label_2.setText(QApplication.translate("GdalToolsWidget", "&Output directory for contour lines (shapefile)"))
self.outSelector.setType(self.outSelector.FILE)
# set the default QSpinBoxes value
self.intervalDSpinBox.setValue(10.0)
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.intervalDSpinBox, SIGNAL("valueChanged(double)")),
(self.attributeEdit, SIGNAL("textChanged(const QString &)"), self.attributeCheck)
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Contour"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
if not self.useDirAsOutput:
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
outputFile, encoding = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the Contour output"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True)
else:
outputFile, encoding = Utils.FileDialog.getExistingDirectory(self, self.tr("Select where to save the Contour output"), True)
if not outputFile:
return
if not self.useDirAsOutput:
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
self.outSelector.setFilename(outputFile)
self.lastEncoding = encoding
def getArguments(self):
arguments = []
if self.attributeCheck.isChecked() and self.attributeEdit.text():
arguments.append("-a")
arguments.append(self.attributeEdit.text())
if True: # XXX in this moment the -i argument is not optional
arguments.append("-i")
arguments.append(unicode(self.intervalDSpinBox.value()))
arguments.append(self.getInputFileName())
arguments.append(self.outSelector.filename())
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
if self.useDirAsOutput:
if self.outSelector.filename():
return self.outSelector.filename() + QDir.separator() + "contour.shp"
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr")
if vl is not None and vl.isValid():
if hasattr(self, 'lastEncoding'):
vl.setProviderEncoding(self.lastEncoding)

View File

@ -1,180 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doDEM.py
---------------------
Date : March 2011
Copyright : (C) 2011 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'March 2011'
__copyright__ = '(C) 2011, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget
from ui_widgetDEM import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.modes = ("hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", "roughness")
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdaldem")
self.outSelector.setType(self.outSelector.FILE)
self.configSelector.setType(self.configSelector.FILE)
# set the default QSpinBoxes and QProgressBar value
self.bandSpin.setValue(1)
self.hillshadeZFactorSpin.setValue(1)
self.hillshadeScaleSpin.setValue(1)
self.hillshadeAltitudeSpin.setValue(45.0)
self.hillshadeAzimuthSpin.setValue(315.0)
self.slopeScaleSpin.setValue(1)
# set the default color configuration file to terrain
import os.path
colorConfigFile = os.path.join(os.path.dirname(__file__), "terrain.txt")
self.configSelector.setFilename(colorConfigFile)
self.outputFormat = Utils.fillRasterOutputFormat()
self.creationOptionsWidget.setFormat(self.outputFormat)
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.computeEdgesCheck, SIGNAL("stateChanged(int)"), None, 1800),
(self.bandSpin, SIGNAL("valueChanged(int)"), self.bandCheck),
(self.algorithmCheck, SIGNAL("stateChanged(int)"), None, 1800),
(self.creationOptionsWidget, SIGNAL("optionsChanged()")),
(self.creationOptionsGroupBox, SIGNAL("toggled(bool)")),
(self.modeCombo, SIGNAL("currentIndexChanged(int)")),
([self.hillshadeZFactorSpin, self.hillshadeScaleSpin, self.hillshadeAltitudeSpin, self.hillshadeAzimuthSpin], SIGNAL("valueChanged(double)")),
(self.slopeScaleSpin, SIGNAL("valueChanged(double)")),
(self.slopePercentCheck, SIGNAL("stateChanged(int)")),
([self.aspectTrigonometricCheck, self.aspectZeroForFlatCheck], SIGNAL("stateChanged(int)")),
(self.configSelector, SIGNAL("filenameChanged()")),
([self.colorExactRadio, self.colorNearestRadio], SIGNAL("toggled(bool)"), self.colorMatchGroupBox),
(self.colorAlphaCheck, SIGNAL("stateChanged(int)"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.configSelector, SIGNAL("selectClicked()"), self.fillColorConfigFileEdit)
self.connect(self.modeCombo, SIGNAL("currentIndexChanged(int)"), self.showModeParams)
def showModeParams(self, index):
self.stackedWidget.setVisible(index < 4)
self.algorithmCheck.setVisible(index < 3)
if index >= 3:
self.algorithmCheck.setChecked(False)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file for DEM"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
self.getArguments()
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
self.creationOptionsWidget.setFormat(self.outputFormat)
def fillColorConfigFileEdit(self):
configFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the color configuration file"))
if not configFile:
return
self.configSelector.setFilename(configFile)
def getArguments(self):
mode = self.modes[self.modeCombo.currentIndex()]
arguments = []
arguments.append(mode)
arguments.append(self.getInputFileName())
if mode == "color-relief":
arguments.append(self.configSelector.filename())
outputFn = self.getOutputFileName()
arguments.append(outputFn)
if mode == "hillshade":
arguments.extend(["-z", self.hillshadeZFactorSpin.value()])
arguments.extend(["-s", self.hillshadeScaleSpin.value()])
arguments.extend(["-az", self.hillshadeAzimuthSpin.value()])
arguments.extend(["-alt", self.hillshadeAltitudeSpin.value()])
elif mode == "slope":
if self.slopePercentCheck.isChecked():
arguments.append("-p")
arguments.extend(["-s", self.slopeScaleSpin.value()])
elif mode == "aspect":
if self.aspectTrigonometricCheck.isChecked():
arguments.append("-trigonometric")
if self.aspectZeroForFlatCheck.isChecked():
arguments.append("-zero_for_flat")
elif mode == "color-relief":
if self.colorAlphaCheck.isChecked():
arguments.append("-alpha")
if self.colorMatchGroupBox.isChecked():
if self.colorExactRadio.isChecked():
arguments.append("-exact_color_entry")
elif self.colorNearestRadio.isChecked():
arguments.append("-nearest_color_entry")
if self.algorithmCheck.isChecked():
arguments.extend(["-alg", "ZevenbergenThorne"])
if self.computeEdgesCheck.isChecked():
arguments.append("-compute_edges")
if self.bandCheck.isChecked():
arguments.extend(["-b", self.bandSpin.value()])
if outputFn:
arguments.extend(["-of", self.outputFormat])
if self.creationOptionsGroupBox.isChecked():
for opt in self.creationOptionsWidget.options():
arguments.extend(["-co", opt])
# set creation options filename/layer for validation
if self.inSelector.layer():
self.creationOptionsWidget.setRasterLayer(self.inSelector.layer())
else:
self.creationOptionsWidget.setRasterFileName(self.getInputFileName())
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())

View File

@ -1,222 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doExtractProj.py
---------------------
Date : August 2011
Copyright : (C) 2011 by Alexander Bruy
Email : alexander dot bruy 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__ = 'Alexander Bruy'
__date__ = 'August 2011'
__copyright__ = '(C) 2011, Alexander Bruy'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import Qt, SIGNAL, QCoreApplication, QObject, QThread, QMutex
from PyQt4.QtGui import QDialog, QDialogButtonBox, QApplication, QCursor, QMessageBox
from ui_dialogExtractProjection import Ui_GdalToolsDialog as Ui_Dialog
import GdalTools_utils as Utils
import os.path
req_mods = {"osgeo": "osgeo [python-gdal]"}
try:
from osgeo import gdal
from osgeo import osr
except ImportError as e:
error_str = e.args[0]
error_mod = error_str.replace("No module named ", "")
if error_mod in req_mods:
error_str = error_str.replace(error_mod, req_mods[error_mod])
raise ImportError(error_str)
class GdalToolsDialog(QDialog, Ui_Dialog):
def __init__(self, iface):
QDialog.__init__(self, iface.mainWindow())
self.setupUi(self)
self.iface = iface
self.inSelector.setType(self.inSelector.FILE)
self.recurseCheck.hide()
self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
self.cancelButton = self.buttonBox.button(QDialogButtonBox.Cancel)
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
def switchToolMode(self):
self.recurseCheck.setVisible(self.batchCheck.isChecked())
self.inSelector.clear()
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
else:
self.label.setText(self.inFileLabel)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file to analyse"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Assign projection"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
def reject(self):
QDialog.reject(self)
def accept(self):
self.inFiles = None
if self.batchCheck.isChecked():
self.inFiles = Utils.getRasterFiles(self.inSelector.filename(), self.recurseCheck.isChecked())
else:
self.inFiles = [self.inSelector.filename()]
self.progressBar.setRange(0, len(self.inFiles))
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.okButton.setEnabled(False)
self.extractor = ExtractThread(self.inFiles, self.prjCheck.isChecked())
QObject.connect(self.extractor, SIGNAL("fileProcessed()"), self.updateProgress)
QObject.connect(self.extractor, SIGNAL("processFinished()"), self.processingFinished)
QObject.connect(self.extractor, SIGNAL("processInterrupted()"), self.processingInterrupted)
QObject.disconnect(self.buttonBox, SIGNAL("rejected()"), self.reject)
QObject.connect(self.buttonBox, SIGNAL("rejected()"), self.stopProcessing)
self.extractor.start()
def updateProgress(self):
self.progressBar.setValue(self.progressBar.value() + 1)
def processingFinished(self):
self.stopProcessing()
QMessageBox.information(self, self.tr("Finished"), self.tr("Processing completed."))
def processingInterrupted(self):
self.restoreGui()
def stopProcessing(self):
if self.extractor is not None:
self.extractor.stop()
self.extractor = None
self.restoreGui()
def restoreGui(self):
self.progressBar.setRange(0, 100)
self.progressBar.setValue(0)
QApplication.restoreOverrideCursor()
QObject.disconnect(self.buttonBox, SIGNAL("rejected()"), self.stopProcessing)
QObject.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
self.okButton.setEnabled(True)
# ----------------------------------------------------------------------
def extractProjection(filename, createPrj):
raster = gdal.Open(unicode(filename))
crs = raster.GetProjection()
geotransform = raster.GetGeoTransform()
raster = None
outFileName = os.path.splitext(unicode(filename))[0]
# create prj file requested and if projection available
if crs != "" and createPrj:
# convert CRS into ESRI format
tmp = osr.SpatialReference()
tmp.ImportFromWkt(crs)
tmp.MorphToESRI()
crs = tmp.ExportToWkt()
tmp = None
prj = open(outFileName + '.prj', 'wt')
prj.write(crs)
prj.close()
# create wld file
wld = open(outFileName + '.wld', 'wt')
wld.write("%0.8f\n" % geotransform[1])
wld.write("%0.8f\n" % geotransform[4])
wld.write("%0.8f\n" % geotransform[2])
wld.write("%0.8f\n" % geotransform[5])
wld.write("%0.8f\n" % (geotransform[0] + 0.5 * geotransform[1] + 0.5 * geotransform[2]))
wld.write("%0.8f\n" % (geotransform[3] + 0.5 * geotransform[4] + 0.5 * geotransform[5]))
wld.close()
class ExtractThread(QThread):
def __init__(self, files, needPrj):
QThread.__init__(self, QThread.currentThread())
self.inFiles = files
self.needPrj = needPrj
self.mutex = QMutex()
self.stopMe = 0
def run(self):
self.mutex.lock()
self.stopMe = 0
self.mutex.unlock()
interrupted = False
for f in self.inFiles:
extractProjection(f, self.needPrj)
self.emit(SIGNAL("fileProcessed()"))
self.mutex.lock()
s = self.stopMe
self.mutex.unlock()
if s == 1:
interrupted = True
break
if not interrupted:
self.emit(SIGNAL("processFinished()"))
else:
self.emit(SIGNAL("processIterrupted()"))
def stop(self):
self.mutex.lock()
self.stopMe = 1
self.mutex.unlock()
QThread.wait(self)

View File

@ -1,236 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doFillNodata.py
---------------------
Date : November 2011
Copyright : (C) 2011 by Alexander Bruy
Email : alexander dot bruy 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__ = 'Alexander Bruy'
__date__ = 'November 2011'
__copyright__ = '(C) 2011, Alexander Bruy'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import Qt, QObject, SIGNAL, QCoreApplication, QDir
from PyQt4.QtGui import QWidget
from ui_widgetFillNodata import Ui_GdalToolsWidget as Ui_Widget
from widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget
import GdalTools_utils as Utils
import re
class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BaseBatchWidget.__init__(self, self.iface, "gdal_fillnodata.py")
self.inSelector.setType(self.inSelector.FILE_LAYER)
self.outSelector.setType(self.outSelector.FILE)
self.maskSelector.setType(self.maskSelector.FILE)
self.progressBar.setValue(0)
self.progressBar.hide()
self.formatLabel.hide()
self.formatCombo.hide()
self.outputFormat = Utils.fillRasterOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.maskSelector, SIGNAL("filenameChanged()"), self.maskCheck),
(self.distanceSpin, SIGNAL("valueChanged( int )"), self.distanceCheck),
(self.smoothSpin, SIGNAL("valueChanged( int )"), self.smoothCheck),
(self.bandSpin, SIGNAL("valueChanged( int )"), self.bandCheck),
(self.nomaskCheck, SIGNAL("stateChanged( int )"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFile)
self.connect(self.maskSelector, SIGNAL("selectClicked()"), self.fillMaskFile)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
# add raster filters to combo
self.formatCombo.addItems(Utils.FileFilter.allRastersFilter().split(";;"))
def switchToolMode(self):
self.setCommandViewerEnabled(not self.batchCheck.isChecked())
self.progressBar.setVisible(self.batchCheck.isChecked())
self.formatLabel.setVisible(self.batchCheck.isChecked())
self.formatCombo.setVisible(self.batchCheck.isChecked())
self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER)
self.outSelector.clear()
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.outFileLabel = self.label_1.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
self.label_1.setText(QCoreApplication.translate("GdalTools", "&Output directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFile)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self. fillInputDir)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
else:
self.label.setText(self.inFileLabel)
self.label_1.setText(self.outFileLabel)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFile)
def fillInputFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self,
self.tr("Select the files to analyse"),
Utils.FileFilter.allRastersFilter(),
lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def fillMaskFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self,
self.tr("Select the files to analyse"),
Utils.FileFilter.allRastersFilter(),
lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.maskSelector.setFilename(inputFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
def fillOutputDir(self):
outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to"))
if not outputDir:
return
self.outSelector.setFilename(outputDir)
def getArguments(self):
arguments = []
maskFile = self.maskSelector.filename()
if self.distanceCheck.isChecked() and self.distanceSpin.value() != 0:
arguments.append("-md")
arguments.append(self.distanceSpin.text())
if self.smoothCheck.isChecked() and self.smoothSpin.value() != 0:
arguments.append("-si")
arguments.append(unicode(self.smoothSpin.value()))
if self.bandCheck.isChecked() and self.bandSpin.value() != 0:
arguments.append("-b")
arguments.append(unicode(self.bandSpin.value()))
if self.maskCheck.isChecked() and maskFile:
arguments.append("-mask")
arguments.append(maskFile)
if self.nomaskCheck.isChecked():
arguments.append("-nomask")
if self.isBatchEnabled():
if self.formatCombo.currentIndex() != 0:
arguments.append("-of")
arguments.append(Utils.fillRasterOutputFormat(self.formatCombo.currentText()))
return arguments
else:
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(self.getInputFileName())
arguments.append(outputFn)
return arguments
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def isBatchEnabled(self):
return self.batchCheck.isChecked()
def setProgressRange(self, maximum):
self.progressBar.setRange(0, maximum)
def updateProgress(self, index, total):
if index < total:
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)
def batchRun(self):
exts = re.sub('\).*$', '', re.sub('^.*\(', '', self.formatCombo.currentText())).split(" ")
if len(exts) > 0 and exts[0] != "*" and exts[0] != "*.*":
outExt = exts[0].replace("*", "")
else:
outExt = ".tif"
self.base.enableRun(False)
self.base.setCursor(Qt.WaitCursor)
inDir = self.getInputFileName()
outDir = self.getOutputFileName()
extensions = Utils.getRasterExtensions()
workDir = QDir(inDir)
workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
workDir.setNameFilters(extensions)
files = workDir.entryList()
self.inFiles = []
self.outFiles = []
for f in files:
self.inFiles.append(inDir + "/" + f)
if outDir is not None:
outFile = re.sub("\.[a-zA-Z0-9]{2,4}", outExt, f)
self.outFiles.append(outDir + "/" + outFile)
self.errors = []
self.batchIndex = 0
self.batchTotal = len(self.inFiles)
self.setProgressRange(self.batchTotal)
self.runItem(self.batchIndex, self.batchTotal)

View File

@ -1,212 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doGrid.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QFileInfo, QTextCodec
from PyQt4.QtGui import QWidget, QErrorMessage
from ui_widgetGrid import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.canvas = self.iface.mapCanvas()
self.algorithm = ('invdist', 'average', 'nearest', 'datametrics')
self.datametrics = ('minimum', 'maximum', 'range')
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_grid")
self.outSelector.setType(self.outSelector.FILE)
self.extentSelector.setCanvas(self.canvas)
#self.extentSelector.stop()
# set the default QSpinBoxes and QProgressBar value
self.widthSpin.setValue(3000)
self.heightSpin.setValue(3000)
self.invdistPowerSpin.setValue(2.0)
self.outputFormat = Utils.fillRasterOutputFormat()
self.lastEncoding = Utils.getLastUsedEncoding()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.zfieldCombo, SIGNAL("currentIndexChanged(int)"), self.zfieldCheck),
(self.algorithmCombo, SIGNAL("currentIndexChanged(int)"), self.algorithmCheck),
(self.stackedWidget, None, self.algorithmCheck),
([self.invdistPowerSpin, self.invdistSmothingSpin, self.invdistRadius1Spin, self.invdistRadius2Spin, self.invdistAngleSpin, self.invdistNoDataSpin], SIGNAL("valueChanged(double)")),
([self.invdistMaxPointsSpin, self.invdistMinPointsSpin], SIGNAL("valueChanged(int)")),
([self.averageRadius1Spin, self.averageRadius2Spin, self.averageAngleSpin, self.averageNoDataSpin], SIGNAL("valueChanged(double)")),
(self.averageMinPointsSpin, SIGNAL("valueChanged(int)")),
([self.nearestRadius1Spin, self.nearestRadius2Spin, self.nearestAngleSpin, self.nearestNoDataSpin], SIGNAL("valueChanged(double)")),
(self.datametricsCombo, SIGNAL("currentIndexChanged(int)")),
([self.datametricsRadius1Spin, self.datametricsRadius2Spin, self.datametricsAngleSpin, self.datametricsNoDataSpin], SIGNAL("valueChanged(double)")),
(self.datametricsMinPointsSpin, SIGNAL("valueChanged(int)")),
(self.extentSelector, [SIGNAL("selectionStarted()"), SIGNAL("newExtentDefined()")], self.extentGroup),
([self.widthSpin, self.heightSpin], SIGNAL("valueChanged(int)"), self.resizeGroupBox)
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.inSelector, SIGNAL("layerChanged()"), self.fillFieldsCombo)
self.connect(self.extentGroup, SIGNAL("toggled(bool)"), self.onExtentCheckedChanged)
def onClosing(self):
self.extentSelector.stop()
BasePluginWidget.onClosing(self)
def onExtentCheckedChanged(self, enabled):
self.extentSelector.start() if enabled else self.extentSelector.stop()
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getVectorLayers())
def fillFieldsCombo(self):
if self.inSelector.layer() is None:
return
self.lastEncoding = self.inSelector.layer().dataProvider().encoding()
self.loadFields(self.getInputFileName())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
inputFile, encoding = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Grid"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True)
if not inputFile:
return
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
self.lastEncoding = encoding
self.loadFields(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def getArguments(self):
arguments = []
if self.zfieldCheck.isChecked() and self.zfieldCombo.currentIndex() >= 0:
arguments.append("-zfield")
arguments.append(self.zfieldCombo.currentText())
inputFn = self.getInputFileName()
if inputFn:
arguments.append("-l")
arguments.append(QFileInfo(inputFn).baseName())
if self.extentGroup.isChecked():
rect = self.extentSelector.getExtent()
if rect is not None:
arguments.append("-txe")
arguments.append(unicode(rect.xMinimum()))
arguments.append(unicode(rect.xMaximum()))
arguments.append("-tye")
arguments.append(unicode(rect.yMaximum()))
arguments.append(unicode(rect.yMinimum()))
if self.algorithmCheck.isChecked() and self.algorithmCombo.currentIndex() >= 0:
arguments.append("-a")
arguments.append(self.algorithmArguments(self.algorithmCombo.currentIndex()))
if self.resizeGroupBox.isChecked():
arguments.append("-outsize")
arguments.append(unicode(self.widthSpin.value()))
arguments.append(unicode(self.heightSpin.value()))
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(inputFn)
arguments.append(outputFn)
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def algorithmArguments(self, index):
algorithm = self.algorithm[index]
arguments = []
if algorithm == "invdist":
arguments.append(algorithm)
arguments.append("power=" + unicode(self.invdistPowerSpin.value()))
arguments.append("smothing=" + unicode(self.invdistSmothingSpin.value()))
arguments.append("radius1=" + unicode(self.invdistRadius1Spin.value()))
arguments.append("radius2=" + unicode(self.invdistRadius2Spin.value()))
arguments.append("angle=" + unicode(self.invdistAngleSpin.value()))
arguments.append("max_points=" + unicode(self.invdistMaxPointsSpin.value()))
arguments.append("min_points=" + unicode(self.invdistMinPointsSpin.value()))
arguments.append("nodata=" + unicode(self.invdistNoDataSpin.value()))
elif algorithm == "average":
arguments.append(algorithm)
arguments.append("radius1=" + unicode(self.averageRadius1Spin.value()))
arguments.append("radius2=" + unicode(self.averageRadius2Spin.value()))
arguments.append("angle=" + unicode(self.averageAngleSpin.value()))
arguments.append("min_points=" + unicode(self.averageMinPointsSpin.value()))
arguments.append("nodata=" + unicode(self.averageNoDataSpin.value()))
elif algorithm == "nearest":
arguments.append(algorithm)
arguments.append("radius1=" + unicode(self.nearestRadius1Spin.value()))
arguments.append("radius2=" + unicode(self.nearestRadius2Spin.value()))
arguments.append("angle=" + unicode(self.nearestAngleSpin.value()))
arguments.append("nodata=" + unicode(self.nearestNoDataSpin.value()))
else:
arguments.append(self.datametrics[self.datametricsCombo.currentIndex()])
arguments.append("radius1=" + unicode(self.datametricsRadius1Spin.value()))
arguments.append("radius2=" + unicode(self.datametricsRadius2Spin.value()))
arguments.append("angle=" + unicode(self.datametricsAngleSpin.value()))
arguments.append("min_points=" + unicode(self.datametricsMinPointsSpin.value()))
arguments.append("nodata=" + unicode(self.datametricsNoDataSpin.value()))
return ':'.join(arguments)
def loadFields(self, vectorFile=''):
self.zfieldCombo.clear()
if not vectorFile:
return
try:
(fields, names) = Utils.getVectorFields(vectorFile)
except Utils.UnsupportedOGRFormat as e:
QErrorMessage(self).showMessage(e.args[0])
self.inSelector.setLayer(None)
return
ncodec = QTextCodec.codecForName(self.lastEncoding)
for name in names:
self.zfieldCombo.addItem(ncodec.toUnicode(name))

View File

@ -1,134 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doInfo.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import Qt, QObject, SIGNAL
from PyQt4.QtGui import QWidget, QAction, QApplication, QMenu
from ui_widgetInfo import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
import platform
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdalinfo")
# we don't need load to canvas functionality
self.base.loadCheckBox.hide()
# make window large
self.base.resize(400, 360)
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.suppressGCPCheck, SIGNAL("stateChanged( int )")),
(self.suppressMDCheck, SIGNAL("stateChanged( int )"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
# helper actions for copying info output
self.copyLine = QAction(self.tr("Copy"), self)
QObject.connect(self.copyLine, SIGNAL("triggered()"), self.doCopyLine)
self.copyAll = QAction(self.tr("Copy all"), self)
QObject.connect(self.copyAll, SIGNAL("triggered()"), self.doCopyAll)
def doCopyLine(self):
output = ''
items = self.rasterInfoList.selectedItems()
for r in items:
output += r.text() + "\n"
if output:
clipboard = QApplication.clipboard()
clipboard.setText(output)
def doCopyAll(self):
output = ''
for r in range(self.rasterInfoList.count()):
output += self.rasterInfoList.item(r).text() + "\n"
if output:
clipboard = QApplication.clipboard()
clipboard.setText(output)
def keyPressEvent(self, e):
if (e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier) and e.key() == Qt.Key_C:
items = ''
for r in range(self.rasterInfoList.count()):
items.append(self.rasterInfoList.item(r).text() + "\n")
if items:
clipboard = QApplication.clipboard()
clipboard.setText(items)
else:
QWidget.keyPressEvent(self, e)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def finished(self):
self.rasterInfoList.clear()
arr = unicode(self.base.process.readAllStandardOutput()).strip()
if platform.system() == "Windows":
#info = QString.fromLocal8Bit( arr ).strip().split( "\r\n" )
# TODO test
info = arr.splitlines()
else:
info = arr.splitlines()
self.rasterInfoList.addItems(info)
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file to analyse"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def getArguments(self):
arguments = []
if self.suppressGCPCheck.isChecked():
arguments.append("-nogcp")
if self.suppressMDCheck.isChecked():
arguments.append("-nomd")
arguments.append(self.getInputFileName())
return arguments
# def getOutputFileName( self ):
# return self.inSelector.filename()
def getInputFileName(self):
return self.inSelector.filename()
def contextMenuEvent(self, event):
menu = QMenu(self)
menu.addAction(self.copyLine)
menu.addAction(self.copyAll)
menu.exec_(event.globalPos())

View File

@ -1,198 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doMerge.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QObject, QCoreApplication
from PyQt4.QtGui import QWidget, QMessageBox
from ui_widgetMerge import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_merge.py")
self.inSelector.setType(self.inSelector.FILE)
self.outSelector.setType(self.outSelector.FILE)
self.recurseCheck.hide()
# use this for approx. previous UI
#self.creationOptionsWidget.setType(QgsRasterFormatSaveOptionsWidget.Table)
self.outputFormat = Utils.fillRasterOutputFormat()
self.extent = None
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.noDataSpin, SIGNAL("valueChanged(int)"), self.noDataCheck),
(self.inputDirCheck, SIGNAL("stateChanged(int)")),
(self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck),
(self.separateCheck, SIGNAL("stateChanged( int )")),
(self.pctCheck, SIGNAL("stateChanged( int )")),
(self.intersectCheck, SIGNAL("stateChanged( int )")),
(self.creationOptionsWidget, SIGNAL("optionsChanged()")),
(self.creationOptionsGroupBox, SIGNAL("toggled(bool)"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.intersectCheck, SIGNAL("toggled(bool)"), self.refreshExtent)
self.connect(self.inputDirCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
self.connect(self.inSelector, SIGNAL("filenameChanged()"), self.refreshExtent)
def switchToolMode(self):
self.recurseCheck.setVisible(self.inputDirCheck.isChecked())
self.inSelector.clear()
if self.inputDirCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
else:
self.label.setText(self.inFileLabel)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
def fillInputFilesEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
files = Utils.FileDialog.getOpenFileNames(self, self.tr("Select the files to Merge"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not files:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(files)
def refreshExtent(self):
files = self.getInputFileNames()
self.intersectCheck.setEnabled(len(files) > 1)
if not self.intersectCheck.isChecked():
self.someValueChanged()
return
if len(files) < 2:
self.intersectCheck.setChecked(False)
return
self.extent = self.getIntersectedExtent(files)
if self.extent is None:
QMessageBox.warning(self, self.tr("Error retrieving the extent"), self.tr('GDAL was unable to retrieve the extent from any file. \nThe "Use intersected extent" option will be unchecked.'))
self.intersectCheck.setChecked(False)
return
elif self.extent.isEmpty():
QMessageBox.warning(self, self.tr("Empty extent"), self.tr('The computed extent is empty. \nDisable the "Use intersected extent" option to have a nonempty output.'))
self.someValueChanged()
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the Merge output"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Merge"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
def getArguments(self):
arguments = []
if self.intersectCheck.isChecked():
if self.extent is not None:
arguments.append("-ul_lr")
arguments.append(unicode(self.extent.xMinimum()))
arguments.append(unicode(self.extent.yMaximum()))
arguments.append(unicode(self.extent.xMaximum()))
arguments.append(unicode(self.extent.yMinimum()))
if self.noDataCheck.isChecked():
arguments.append("-n")
arguments.append(unicode(self.noDataSpin.value()))
if Utils.GdalConfig.versionNum() >= 1900:
arguments.append("-a_nodata")
arguments.append(unicode(self.noDataSpin.value()))
if self.separateCheck.isChecked():
arguments.append("-separate")
if self.pctCheck.isChecked():
arguments.append("-pct")
if self.creationOptionsGroupBox.isChecked():
for opt in self.creationOptionsWidget.options():
arguments.append("-co")
arguments.append(opt)
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append("-o")
arguments.append(outputFn)
arguments.extend(self.getInputFileNames())
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
if self.inputDirCheck.isChecked():
return self.inSelector.filename()
return self.inSelector.filename().split(",")
def getInputFileNames(self):
if self.inputDirCheck.isChecked():
return Utils.getRasterFiles(self.inSelector.filename(), self.recurseCheck.isChecked())
return self.inSelector.filename().split(",")
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def getIntersectedExtent(self, files):
res = None
for fileName in files:
if res is None:
res = Utils.getRasterExtent(self, fileName)
continue
rect2 = Utils.getRasterExtent(self, fileName)
if rect2 is None:
continue
res = res.intersect(rect2)
if res.isEmpty():
break
return res

View File

@ -1,98 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doNearBlack.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget
from ui_widgetNearBlack import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "nearblack")
self.outSelector.setType(self.outSelector.FILE)
# set the default QSpinBoxes value
self.nearSpin.setValue(15)
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.nearSpin, SIGNAL("valueChanged(int)"), self.nearCheck),
(self.whiteCheckBox, SIGNAL("stateChanged(int)"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Near Black"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outSelector.setFilename(outputFile)
def getArguments(self):
arguments = []
if self.whiteCheckBox.isChecked():
arguments.append("-white")
if self.nearCheck.isChecked():
arguments.append("-near")
arguments.append(unicode(self.nearSpin.value()))
arguments.append("-o")
arguments.append(self.getOutputFileName())
arguments.append(self.getInputFileName())
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
return self.inSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())

View File

@ -1,198 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doOverview.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import QObject, SIGNAL, QCoreApplication
from PyQt4.QtGui import QWidget
from qgis.core import QgsRaster
from ui_widgetOverview import Ui_GdalToolsWidget as Ui_Widget
from widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.resampling_method = ('nearest', 'average', 'gauss', 'cubic', 'average_mp', 'average_magphase', 'mode')
self.setupUi(self)
BaseBatchWidget.__init__(self, self.iface, "gdaladdo")
# set the default QSpinBoxes and QProgressBar value
self.progressBar.setValue(0)
self.progressBar.hide()
# we don't need load to canvas functionality
self.base.loadCheckBox.hide()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.cleanCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.mPyramidOptionsWidget, SIGNAL("overviewListChanged()")),
(self.mPyramidOptionsWidget, SIGNAL("someValueChanged()"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
self.init = False # workaround bug that pyramid options widgets are not initialized at first
# make sure we get a command line when dialog appears
def show_(self):
BaseBatchWidget.show_(self)
self.someValueChanged()
# switch to batch or normal mode
def switchToolMode(self):
self.setCommandViewerEnabled(not self.batchCheck.isChecked())
self.progressBar.setVisible(self.batchCheck.isChecked())
self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER)
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
else:
self.label.setText(self.inFileLabel)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if inputFile == '':
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
self.mPyramidOptionsWidget.setRasterLayer(None)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files"))
if inputDir == '':
return
self.inSelector.setFilename(inputDir)
def getArguments(self):
arguments = []
arguments.append("-r")
arguments.append(self.mPyramidOptionsWidget.resamplingMethod())
format = self.mPyramidOptionsWidget.pyramidsFormat()
if format == QgsRaster.PyramidsGTiff:
arguments.append("-ro")
elif format == QgsRaster.PyramidsErdas:
arguments.append("--config")
arguments.append("USE_RRD")
arguments.append("YES")
for option in self.mPyramidOptionsWidget.configOptions():
(k, v) = option.split("=")
arguments.append("--config")
arguments.append(unicode(k))
arguments.append(unicode(v))
if self.cleanCheck.isChecked():
arguments.append("-clean")
# TODO fix batch enabled, argument order is wrong, levels not at end
if self.isBatchEnabled():
return arguments
arguments.append(self.getInputFileName())
if len(self.mPyramidOptionsWidget.overviewList()) > 0:
for level in self.mPyramidOptionsWidget.overviewList():
arguments.append(unicode(level))
# set creation options filename/layer for validation
if self.init:
if self.isBatchEnabled():
self.mPyramidOptionsWidget.setRasterLayer(None)
elif self.inSelector.layer():
self.mPyramidOptionsWidget.setRasterLayer(self.inSelector.layer())
else:
self.mPyramidOptionsWidget.setRasterFileName(self.getInputFileName())
else:
self.init = True
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.inSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def getBatchArguments(self, inFile, outFile=None):
arguments = self.getArguments()
arguments.append(inFile)
if len(self.mPyramidOptionsWidget.overviewList()) == 0:
arguments.extend(["2", "4", "8", "16", "32"])
else:
for level in self.mPyramidOptionsWidget.overviewList():
arguments.append(unicode(level))
return arguments
def isBatchEnabled(self):
return self.batchCheck.isChecked()
def onFinished(self, exitCode, status):
if not self.isBatchEnabled():
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
BasePluginWidget.onFinished(self, exitCode, status)
return
msg = unicode(self.base.process.readAllStandardError())
if msg != '':
self.errors.append(">> " + self.inFiles[self.batchIndex] + "<br>" + msg.replace("\n", "<br>"))
self.base.process.close()
self.batchIndex += 1
self.runItem(self.batchIndex, self.batchTotal)
def setProgressRange(self, maximum):
self.progressBar.setRange(0, maximum)
def updateProgress(self, index, total):
if index < total:
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)

View File

@ -1,163 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doPctRgb.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import QObject, SIGNAL, QCoreApplication
from PyQt4.QtGui import QWidget
from ui_widgetConvert import Ui_GdalToolsWidget as Ui_Widget
from widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BaseBatchWidget.__init__(self, self.iface, "pct2rgb.py")
# we use one widget for two tools
self.base.setWindowTitle(self.tr("Convert paletted image to RGB"))
self.outSelector.setType(self.outSelector.FILE)
# set the default QSpinBoxes and QProgressBar value
self.bandSpin.setValue(1)
self.progressBar.setValue(0)
self.progressBar.hide()
self.outputFormat = Utils.fillRasterOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.colorsSpin, SIGNAL("valueChanged(int)"), self.colorsCheck, "-1"), # hide this option
(self.bandSpin, SIGNAL("valueChanged(int)"), self.bandCheck)
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
# switch to batch or normal mode
def switchToolMode(self):
self.setCommandViewerEnabled(not self.batchCheck.isChecked())
self.progressBar.setVisible(self.batchCheck.isChecked())
self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER)
self.outSelector.clear()
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.outFileLabel = self.label_2.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
else:
self.label.setText(self.inFileLabel)
self.label_2.setText(self.outFileLabel)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for convert"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files for convert"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
def fillOutputDir(self):
outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to"))
if not outputDir:
return
self.outSelector.setFilename(outputDir)
def getArguments(self):
arguments = []
if self.bandCheck.isChecked():
arguments.append("-b")
arguments.append(unicode(self.bandSpin.value()))
if self.isBatchEnabled():
return arguments
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(self.getInputFileName())
arguments.append(outputFn)
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def isBatchEnabled(self):
return self.batchCheck.isChecked()
def setProgressRange(self, maximum):
self.progressBar.setRange(0, maximum)
def updateProgress(self, index, total):
if index < total:
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)

View File

@ -1,122 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doPolygonize.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QFileInfo
from PyQt4.QtGui import QWidget
from ui_widgetPolygonize import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.resolutions = ("highest", "average", "lowest")
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_polygonize.py")
self.outSelector.setType(self.outSelector.FILE)
self.outputFormat = Utils.fillVectorOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.maskSelector, SIGNAL("filenameChanged()"), self.maskCheck),
(self.fieldEdit, SIGNAL("textChanged(const QString &)"), self.fieldCheck)
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.maskSelector, SIGNAL("selectClicked()"), self.fillMaskFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
self.maskSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Polygonize"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
outputFile, encoding = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the Polygonize output"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True)
if not outputFile:
return
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
self.outputFormat = Utils.fillVectorOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
self.lastEncoding = encoding
def fillMaskFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
maskFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Polygonize"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not maskFile():
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.maskSelector.setFilename(maskFile)
def getArguments(self):
arguments = []
arguments.append(self.getInputFileName())
outputFn = self.getOutputFileName()
maskFn = self.getMaskFileName()
if self.maskCheck.isChecked() and maskFn:
arguments.append("-mask")
arguments.append(maskFn)
if outputFn:
arguments.append("-f")
arguments.append(self.outputFormat)
arguments.append(outputFn)
if outputFn:
arguments.append(QFileInfo(outputFn).baseName())
if (self.fieldCheck.isChecked() and self.fieldEdit.text()):
arguments.append(self.fieldEdit.text())
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
return self.inSelector.filename()
def getMaskFileName(self):
return self.maskSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr")
if vl is not None and vl.isValid():
if hasattr(self, 'lastEncoding'):
vl.setProviderEncoding(self.lastEncoding)

View File

@ -1,190 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doProjection.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import Qt, QObject, SIGNAL, QCoreApplication, QFile, QFileInfo
from PyQt4.QtGui import QWidget, QMessageBox
from qgis.core import QgsMapLayerRegistry, QgsMapLayer
from ui_widgetProjection import Ui_GdalToolsWidget as Ui_Widget
from widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget
from dialogSRS import GdalToolsSRSDialog as SRSDialog
import GdalTools_utils as Utils
import re
class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BaseBatchWidget.__init__(self, self.iface, "gdalwarp")
self.inSelector.setType(self.inSelector.FILE)
# set the default QSpinBoxes and QProgressBar value
self.progressBar.setValue(0)
self.progressBar.hide()
self.recurseCheck.hide()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.desiredSRSEdit, SIGNAL("textChanged( const QString & )"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.selectDesiredSRSButton, SIGNAL("clicked()"), self.fillDesiredSRSEdit)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
self.connect(self.recurseCheck, SIGNAL("stateChanged( int )"), self.enableRecurse)
def switchToolMode(self):
self.setCommandViewerEnabled(not self.batchCheck.isChecked())
self.progressBar.setVisible(self.batchCheck.isChecked())
self.recurseCheck.setVisible(self.batchCheck.isChecked())
self.inSelector.clear()
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
else:
self.label.setText(self.inFileLabel)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
def enableRecurse(self):
if self.recurseCheck.isChecked():
res = QMessageBox.warning(self, self.tr("Warning"),
self.tr("Warning: CRS information for all raster in subfolders will be rewritten. Are you sure?"),
QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
self.recurseCheck.setCheckState(Qt.Unchecked)
return
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the file to analyse"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Assign projection"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
def fillDesiredSRSEdit(self):
dialog = SRSDialog("Select desired SRS", self)
if dialog.exec_():
self.desiredSRSEdit.setText(dialog.getProjection())
def getArguments(self):
arguments = []
if self.desiredSRSEdit.text():
arguments.append("-t_srs")
arguments.append(self.desiredSRSEdit.text())
if self.batchCheck.isChecked():
return arguments
inputFn = self.getInputFileName()
arguments.append(inputFn)
self.tempFile = inputFn
self.needOverwrite = False
if self.tempFile:
if self.tempFile.lower().endswith(".tif") or self.tempFile.lower().endswith(".tiff"):
self.tempFile = re.sub("\.[a-zA-Z]{2,4}$", ".tif", self.tempFile) + ".tmp"
self.needOverwrite = True
else:
self.tempFile = re.sub("\.[a-zA-Z]{2,4}$", ".tif", self.tempFile)
arguments.append(self.tempFile)
return arguments
def finished(self):
outFn = self.getOutputFileName()
if self.needOverwrite:
oldFile = QFile(outFn)
newFile = QFile(self.tempFile)
if oldFile.remove():
newFile.rename(outFn)
fileInfo = QFileInfo(outFn)
if fileInfo.exists():
if self.base.loadCheckBox.isChecked():
self.addLayerIntoCanvas(fileInfo)
QMessageBox.information(self, self.tr("Finished"), self.tr("Processing completed."))
else:
QMessageBox.warning(self, self.tr("Warning"), self.tr("{0} not created.").format(outFn))
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.inSelector.filename()
def getBatchOutputFileName(self, fn):
# get GeoTiff
fn = re.sub(r'\.[a-zA-Z]{2,4}$', r'.tif', fn)
return BaseBatchWidget.getBatchOutputFileName(self, fn)
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def checkLayer(self):
layerList = []
layerMap = QgsMapLayerRegistry.instance().mapLayers()
for name, layer in layerMap.iteritems():
if layer.type() == QgsMapLayer.RasterLayer:
layerList.append(unicode(layer.source()))
if unicode(self.inputFileEdit.text()) in layerList:
QMessageBox.warning(self, self.tr("Assign projection"), self.tr("This raster already found in map canvas"))
return
self.onRun()
def isBatchEnabled(self):
return self.batchCheck.isChecked()
def isRecursiveScanEnabled(self):
return self.recurseCheck.isChecked()
def setProgressRange(self, maximum):
self.progressBar.setRange(0, maximum)
def updateProgress(self, index, total):
if index < total:
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)

View File

@ -1,115 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doProximity.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget
from ui_widgetProximity import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_proximity.py")
self.outSelector.setType(self.outSelector.FILE)
self.outputFormat = Utils.fillRasterOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.valuesEdit, SIGNAL("textChanged(const QString &)"), self.valuesCheck),
(self.distUnitsCombo, SIGNAL("currentIndexChanged(int)"), self.distUnitsCheck),
(self.maxDistSpin, SIGNAL("valueChanged(int)"), self.maxDistCheck),
(self.noDataSpin, SIGNAL("valueChanged(int)"), self.noDataCheck),
(self.fixedBufValSpin, SIGNAL("valueChanged(int)"), self.fixedBufValCheck)
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry().getRasterLayers())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Proximity"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def getArguments(self):
arguments = []
arguments.append(self.getInputFileName())
outputFn = self.getOutputFileName()
arguments.append(outputFn)
if self.valuesCheck.isChecked():
values = self.valuesEdit.text().split()
if values:
arguments.append("-values")
arguments.append(','.join(values))
if self.distUnitsCheck.isChecked() and self.distUnitsCombo.currentIndex() >= 0:
arguments.append("-distunits")
arguments.append(self.distUnitsCombo.currentText())
if self.maxDistCheck.isChecked():
arguments.append("-maxdist")
arguments.append(unicode(self.maxDistSpin.value()))
if self.noDataCheck.isChecked():
arguments.append("-nodata")
arguments.append(unicode(self.noDataSpin.value()))
if self.fixedBufValCheck.isChecked():
arguments.append("-fixed-buf-val")
arguments.append(unicode(self.fixedBufValSpin.value()))
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
return self.inSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())

View File

@ -1,158 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doRasterize.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QFileInfo, QTextCodec
from PyQt4.QtGui import QWidget, QMessageBox, QErrorMessage
from ui_widgetRasterize import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_rasterize")
self.outSelector.setType(self.outSelector.FILE)
# set the default QSpinBoxes and QProgressBar value
self.widthSpin.setValue(3000)
self.heightSpin.setValue(3000)
self.horizresSpin.setValue(1)
self.vertresSpin.setValue(1)
self.lastEncoding = Utils.getLastUsedEncoding()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.attributeComboBox, SIGNAL("currentIndexChanged(int)")),
([self.widthSpin, self.heightSpin], SIGNAL("valueChanged(int)")),
([self.horizresSpin, self.vertresSpin], SIGNAL("valueChanged(double)"))
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.inSelector, SIGNAL("layerChanged()"), self.fillFieldsCombo)
self.connect(self.radioSetSize, SIGNAL("toggled(bool)"), self.someValueChanged)
self.connect(self.radioSetResolution, SIGNAL("toggled(bool)"), self.someValueChanged)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getVectorLayers())
def fillFieldsCombo(self):
if self.inSelector.layer() is None:
return
self.lastEncoding = self.inSelector.layer().dataProvider().encoding()
self.loadFields(self.getInputFileName())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
inputFile, encoding = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Rasterize"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True)
if not inputFile:
return
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
self.lastEncoding = encoding
self.loadFields(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
# rasterize supports output file creation for GDAL 1.8
gdalVersion = Utils.GdalConfig.versionNum()
if gdalVersion >= 1800:
fileDialogFunc = Utils.FileDialog.getSaveFileName
filters = Utils.FileFilter.saveRastersFilter()
else:
fileDialogFunc = Utils.FileDialog.getOpenFileName
filters = Utils.FileFilter.allRastersFilter()
outputFile = fileDialogFunc(self, self.tr("Select the raster file to save the results to"), filters, lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outSelector.setFilename(outputFile)
# required either -ts or -tr to create the output file
if gdalVersion >= 1800:
if not QFileInfo(outputFile).exists():
QMessageBox.information(self, self.tr("Output size or resolution required"), self.tr("The output file doesn't exist. You must set up the output size or resolution to create it."))
self.radioSetSize.setChecked(True)
def getArguments(self):
arguments = []
if self.attributeComboBox.currentIndex() >= 0:
arguments.append("-a")
arguments.append(self.attributeComboBox.currentText())
if self.radioSetSize.isChecked():
arguments.append("-ts")
arguments.append(self.widthSpin.value())
arguments.append(self.heightSpin.value())
if self.radioSetResolution.isChecked():
arguments.append("-tr")
arguments.append(self.horizresSpin.value())
arguments.append(self.vertresSpin.value())
inputFn = self.getInputFileName()
if inputFn:
arguments.append("-l")
arguments.append(QFileInfo(inputFn).baseName())
arguments.append(inputFn)
arguments.append(self.getOutputFileName())
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def loadFields(self, vectorFile):
self.attributeComboBox.clear()
if not vectorFile:
return
try:
(fields, names) = Utils.getVectorFields(vectorFile)
except Utils.UnsupportedOGRFormat as e:
QErrorMessage(self).showMessage(e.args[0])
self.inSelector.setLayer(None)
return
ncodec = QTextCodec.codecForName(self.lastEncoding)
for name in names:
self.attributeComboBox.addItem(ncodec.toUnicode(name))

View File

@ -1,160 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doRgbPct.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QObject, QCoreApplication
from PyQt4.QtGui import QWidget
from ui_widgetConvert import Ui_GdalToolsWidget as Ui_Widget
from widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BaseBatchWidget.__init__(self, self.iface, "rgb2pct.py")
self.outSelector.setType(self.outSelector.FILE)
# set the default QSpinBoxes and QProgressBar value
self.colorsSpin.setValue(2)
self.progressBar.setValue(0)
self.progressBar.hide()
self.outputFormat = Utils.fillRasterOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.colorsSpin, SIGNAL("valueChanged(int)"), self.colorsCheck),
(self.bandSpin, SIGNAL("valueChanged(int)"), self.bandCheck, "-1") # hide this option
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
# switch to batch or normal mode
def switchToolMode(self):
self.setCommandViewerEnabled(not self.batchCheck.isChecked())
self.progressBar.setVisible(self.batchCheck.isChecked())
self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER)
self.outSelector.clear()
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.outFileLabel = self.label_2.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
else:
self.label.setText(self.inFileLabel)
self.label_2.setText(self.outFileLabel)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for convert"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files for convert"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
def fillOutputDir(self):
outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to"))
if not outputDir:
return
self.outSelector.setFilename(outputDir)
def getArguments(self):
arguments = []
if self.colorsCheck.isChecked():
arguments.append("-n")
arguments.append(unicode(self.colorsSpin.value()))
if self.isBatchEnabled():
return arguments
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(self.getInputFileName())
arguments.append(outputFn)
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def isBatchEnabled(self):
return self.batchCheck.isChecked()
def setProgressRange(self, maximum):
self.progressBar.setRange(0, maximum)
def updateProgress(self, index, total):
if index < total:
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)

View File

@ -1,94 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doSettings.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import Qt, SIGNAL, QObject
from PyQt4.QtGui import QDialog, QPixmap
from ui_dialogSettings import Ui_GdalToolsSettingsDialog as Ui_Dialog
import GdalTools_utils as Utils
class GdalToolsSettingsDialog(QDialog, Ui_Dialog):
def __init__(self, iface):
QDialog.__init__(self, iface.mainWindow())
self.setAttribute(Qt.WA_DeleteOnClose)
self.iface = iface
self.setupUi(self)
# binaries
self.leGdalBinPath.setText(Utils.getGdalBinPath())
QObject.connect(self.btnSetBinPath, SIGNAL("clicked()"), self.setBinPath)
self.bin_tooltip_label.setPixmap(QPixmap(':/icons/tooltip.png'))
self.bin_tooltip_label.setToolTip( self.tr( u"""\
A list of colon-separated (Linux and MacOS) or
semicolon-separated (Windows) paths to both binaries
and python executables.
MacOS users usually need to set it to something like
/Library/Frameworks/GDAL.framework/Versions/1.8/Programs""") )
# python modules
self.leGdalPymodPath.setText(Utils.getGdalPymodPath())
QObject.connect(self.btnSetPymodPath, SIGNAL("clicked()"), self.setPymodPath)
self.pymod_tooltip_label.setPixmap(QPixmap(':/icons/tooltip.png'))
self.pymod_tooltip_label.setToolTip( self.tr( u"""\
A list of colon-separated (Linux and MacOS) or
semicolon-separated (Windows) paths to python modules.""") )
# help
self.leGdalHelpPath.setText(Utils.getHelpPath())
QObject.connect(self.btnSetHelpPath, SIGNAL("clicked()"), self.setHelpPath)
self.help_tooltip_label.setPixmap(QPixmap(':/icons/tooltip.png'))
self.help_tooltip_label.setToolTip( self.tr( u"""\
Useful to open local GDAL documentation instead of online help
when pressing on the tool dialog's Help button.""") )
def setBinPath(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select directory with GDAL executables"))
if not inputDir:
return
self.leGdalBinPath.setText(inputDir)
def setPymodPath(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select directory with GDAL python modules"))
if not inputDir:
return
self.leGdalPymodPath.setText(inputDir)
def setHelpPath(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select directory with the GDAL documentation"))
if not inputDir:
return
self.leGdalHelpPath.setText(inputDir)
def accept(self):
Utils.setGdalBinPath(self.leGdalBinPath.text())
Utils.setGdalPymodPath(self.leGdalPymodPath.text())
Utils.setHelpPath(self.leGdalHelpPath.text())
QDialog.accept(self)

View File

@ -1,100 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doSieve.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget
from ui_widgetSieve import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdal_sieve.py")
self.outSelector.setType(self.outSelector.FILE)
self.outputFormat = Utils.fillRasterOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.thresholdSpin, SIGNAL("valueChanged(int)"), self.thresholdCheck),
(self.connectionsCombo, SIGNAL("currentIndexChanged(int)"), self.connectionsCheck)
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFileEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Sieve"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def getArguments(self):
arguments = []
if self.thresholdCheck.isChecked():
arguments.append("-st")
arguments.append(unicode(self.thresholdSpin.value()))
if self.connectionsCheck.isChecked() and self.connectionsCombo.currentIndex() >= 0:
arguments.append("-" + self.connectionsCombo.currentText())
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(self.getInputFileName())
arguments.append(outputFn)
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
return self.inSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())

View File

@ -1,95 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doTileIndex.py
---------------------
Date : February 2011
Copyright : (C) 2011 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'February 2011'
__copyright__ = '(C) 2011, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget
from ui_widgetTileIndex import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdaltindex")
self.inSelector.setType(self.inSelector.FILE)
self.outSelector.setType(self.outSelector.FILE)
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
#( self.recurseCheck, SIGNAL( "stateChanged( int )" ),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.indexFieldEdit, SIGNAL("textChanged( const QString & )"), self.indexFieldCheck),
(self.skipDifferentProjCheck, SIGNAL("stateChanged( int )"), None, 1500)
])
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDirEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def fillInputDirEdit(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with raster files"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
outputFile, encoding = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the TileIndex output"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True)
if not outputFile:
return
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
self.outputFormat = Utils.fillVectorOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
self.lastEncoding = encoding
def getArguments(self):
arguments = []
if self.indexFieldCheck.isChecked() and self.indexFieldEdit.text():
arguments.append("-tileindex")
arguments.append(self.indexFieldEdit.text())
if self.skipDifferentProjCheck.isChecked():
arguments.append("-skip_different_projection")
arguments.append(self.getOutputFileName())
arguments.extend(Utils.getRasterFiles(self.getInputFileName(), self.recurseCheck.isChecked()))
return arguments
def getOutputFileName(self):
return self.outSelector.filename()
def getInputFileName(self):
return self.inSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
vl = self.iface.addVectorLayer(fileInfo.filePath(), fileInfo.baseName(), "ogr")
if vl is not None and vl.isValid():
if hasattr(self, 'lastEncoding'):
vl.setProviderEncoding(self.lastEncoding)

View File

@ -1,306 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doTranslate.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import QObject, Qt, SIGNAL, QCoreApplication, QDir
from PyQt4.QtGui import QWidget, QMessageBox
from ui_widgetTranslate import Ui_GdalToolsWidget as Ui_Widget
from widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget
from dialogSRS import GdalToolsSRSDialog as SRSDialog
import GdalTools_utils as Utils
import re
class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.canvas = self.iface.mapCanvas()
self.expand_method = ('gray', 'rgb', 'rgba')
self.setupUi(self)
BaseBatchWidget.__init__(self, self.iface, "gdal_translate")
self.outSelector.setType(self.outSelector.FILE)
# set the default QSpinBoxes and QProgressBar value
self.outsizeSpin.setValue(25)
self.progressBar.setValue(0)
self.progressBar.hide()
self.formatLabel.hide()
self.formatCombo.hide()
if Utils.GdalConfig.versionNum() < 1700:
index = self.expandCombo.findText('gray', Qt.MatchFixedString)
if index >= 0:
self.expandCombo.removeItem(index)
self.outputFormat = Utils.fillRasterOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.targetSRSEdit, SIGNAL("textChanged(const QString &)"), self.targetSRSCheck),
(self.selectTargetSRSButton, None, self.targetSRSCheck),
(self.creationOptionsWidget, SIGNAL("optionsChanged()")),
(self.outsizeSpin, SIGNAL("valueChanged(const QString &)"), self.outsizeCheck),
(self.nodataSpin, SIGNAL("valueChanged(int)"), self.nodataCheck),
(self.expandCombo, SIGNAL("currentIndexChanged(int)"), self.expandCheck, 1600),
(self.sdsCheck, SIGNAL("stateChanged(int)")),
(self.srcwinEdit, SIGNAL("textChanged(const QString &)"), self.srcwinCheck),
(self.prjwinEdit, SIGNAL("textChanged(const QString &)"), self.prjwinCheck)
])
#self.connect(self.canvas, SIGNAL("layersChanged()"), self.fillInputLayerCombo)
self.connect(self.inSelector, SIGNAL("layerChanged()"), self.fillTargetSRSEditDefault)
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.selectTargetSRSButton, SIGNAL("clicked()"), self.fillTargetSRSEdit)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
# add raster filters to combo
self.formatCombo.addItems(Utils.FileFilter.allRastersFilter().split(";;"))
def switchToolMode(self):
self.setCommandViewerEnabled(not self.batchCheck.isChecked())
self.progressBar.setVisible(self.batchCheck.isChecked())
self.formatLabel.setVisible(self.batchCheck.isChecked())
self.formatCombo.setVisible(self.batchCheck.isChecked())
self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER)
self.outSelector.clear()
if self.batchCheck.isChecked():
self.inFileLabel = self.label_3.text()
self.outFileLabel = self.label_2.text()
self.label_3.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self. fillInputDir)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
else:
self.label_3.setText(self.inFileLabel)
self.label_2.setText(self.outFileLabel)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
def fillInputFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Translate"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
# get SRS for target file if necessary and possible
self.refreshTargetSRS()
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Translate"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
filter = Utils.getRasterExtensions()
workDir = QDir(inputDir)
workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
workDir.setNameFilters(filter)
# search for a valid SRS, then use it as default target SRS
srs = ''
for fname in workDir.entryList():
fl = inputDir + "/" + fname
srs = Utils.getRasterSRS(self, fl)
if srs:
break
self.targetSRSEdit.setText(srs)
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def fillOutputDir(self):
outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to"))
if not outputDir:
return
self.outSelector.setFilename(outputDir)
def fillTargetSRSEditDefault(self):
if self.inSelector.layer() is None:
return
self.refreshTargetSRS()
def refreshTargetSRS(self):
self.targetSRSEdit.setText(Utils.getRasterSRS(self, self.getInputFileName()))
def fillTargetSRSEdit(self):
dialog = SRSDialog("Select the target SRS", self)
if dialog.exec_():
self.targetSRSEdit.setText(dialog.getProjection())
def getArguments(self):
arguments = []
if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text():
arguments.append("-a_srs")
arguments.append(self.targetSRSEdit.text())
if self.creationOptionsGroupBox.isChecked():
for opt in self.creationOptionsWidget.options():
arguments.extend(["-co", opt])
if self.outsizeCheck.isChecked() and self.outsizeSpin.value() != 100:
arguments.append("-outsize")
arguments.append(self.outsizeSpin.text())
arguments.append(self.outsizeSpin.text())
if self.expandCheck.isChecked():
arguments.append("-expand")
arguments.append(self.expand_method[self.expandCombo.currentIndex()])
if self.nodataCheck.isChecked():
arguments.append("-a_nodata")
arguments.append(unicode(self.nodataSpin.value()))
if self.sdsCheck.isChecked():
arguments.append("-sds")
if self.srcwinCheck.isChecked() and self.srcwinEdit.text():
coordList = self.srcwinEdit.text().split() # split the string on whitespace(s)
if len(coordList) == 4 and coordList[3]:
try:
for x in coordList:
int(x)
except ValueError:
#print "Coordinates must be integer numbers."
QMessageBox.critical(self, self.tr("Translate - srcwin"), self.tr("Image coordinates (pixels) must be integer numbers."))
else:
arguments.append("-srcwin")
for x in coordList:
arguments.append(x)
if self.prjwinCheck.isChecked() and self.prjwinEdit.text():
coordList = self.prjwinEdit.text().split() # split the string on whitespace(s)
if len(coordList) == 4 and coordList[3]:
try:
for x in coordList:
float(x)
except ValueError:
#print "Coordinates must be integer numbers."
QMessageBox.critical(self, self.tr("Translate - prjwin"), self.tr("Image coordinates (geographic) must be numbers."))
else:
arguments.append("-projwin")
for x in coordList:
arguments.append(x)
if self.isBatchEnabled():
if self.formatCombo.currentIndex() != 0:
arguments.append("-of")
arguments.append(Utils.fillRasterOutputFormat(self.formatCombo.currentText()))
return arguments
else:
return arguments
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(self.getInputFileName())
arguments.append(outputFn)
# set creation options filename/layer for validation
if self.inSelector.layer():
self.creationOptionsWidget.setRasterLayer(self.inSelector.layer())
else:
self.creationOptionsWidget.setRasterFileName(self.getInputFileName())
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def isBatchEnabled(self):
return self.batchCheck.isChecked()
def setProgressRange(self, maximum):
self.progressBar.setRange(0, maximum)
def updateProgress(self, index, total):
if index < total:
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)
def batchRun(self):
exts = re.sub('\).*$', '', re.sub('^.*\(', '', self.formatCombo.currentText())).split(" ")
if len(exts) > 0 and exts[0] != "*" and exts[0] != "*.*":
outExt = exts[0].replace("*", "")
else:
outExt = ".tif"
self.base.enableRun(False)
self.base.setCursor(Qt.WaitCursor)
inDir = self.getInputFileName()
outDir = self.getOutputFileName()
filter = Utils.getRasterExtensions()
workDir = QDir(inDir)
workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
workDir.setNameFilters(filter)
files = workDir.entryList()
self.inFiles = []
self.outFiles = []
for f in files:
self.inFiles.append(inDir + "/" + f)
if outDir is not None:
outFile = re.sub("\.[a-zA-Z0-9]{2,4}", outExt, f)
self.outFiles.append(outDir + "/" + outFile)
self.errors = []
self.batchIndex = 0
self.batchTotal = len(self.inFiles)
self.setProgressRange(self.batchTotal)
self.runItem(self.batchIndex, self.batchTotal)

View File

@ -1,250 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
doWarp.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import QObject, QCoreApplication, SIGNAL, QDir
from PyQt4.QtGui import QWidget
from qgis.core import QGis
from ui_widgetWarp import Ui_GdalToolsWidget as Ui_Widget
from widgetBatchBase import GdalToolsBaseBatchWidget as BaseBatchWidget
from dialogSRS import GdalToolsSRSDialog as SRSDialog
import GdalTools_utils as Utils
class GdalToolsDialog(QWidget, Ui_Widget, BaseBatchWidget):
def __init__(self, iface):
QWidget.__init__(self)
self.iface = iface
self.resampling_method = ('near', 'bilinear', 'cubic', 'cubicspline', 'lanczos')
self.setupUi(self)
BaseBatchWidget.__init__(self, self.iface, "gdalwarp")
self.outSelector.setType(self.outSelector.FILE)
# set the default QSpinBoxes and QProgressBar value
self.widthSpin.setValue(3000)
self.heightSpin.setValue(3000)
self.progressBar.setValue(0)
self.progressBar.hide()
self.outputFormat = Utils.fillRasterOutputFormat()
self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.sourceSRSEdit, SIGNAL("textChanged(const QString &)"), self.sourceSRSCheck),
(self.selectSourceSRSButton, None, self.sourceSRSCheck),
(self.targetSRSEdit, SIGNAL("textChanged(const QString &)"), self.targetSRSCheck),
(self.selectTargetSRSButton, None, self.targetSRSCheck),
(self.resamplingCombo, SIGNAL("currentIndexChanged(int)"), self.resamplingCheck),
(self.cacheSpin, SIGNAL("valueChanged(int)"), self.cacheCheck),
([self.widthSpin, self.heightSpin], SIGNAL("valueChanged(int)"), self.resizeGroupBox),
(self.multithreadCheck, SIGNAL("stateChanged(int)")),
(self.noDataEdit, SIGNAL("textChanged( const QString & )"), self.noDataCheck),
(self.maskSelector, SIGNAL("filenameChanged()"), self.maskCheck, 1600),
])
self.connect(self.inSelector, SIGNAL("layerChanged()"), self.fillSourceSRSEditDefault)
self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.selectSourceSRSButton, SIGNAL("clicked()"), self.fillSourceSRSEdit)
self.connect(self.selectTargetSRSButton, SIGNAL("clicked()"), self.fillTargetSRSEdit)
self.connect(self.maskSelector, SIGNAL("selectClicked()"), self.fillMaskFile)
self.connect(self.batchCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
# switch to batch or normal mode
def switchToolMode(self):
self.setCommandViewerEnabled(not self.batchCheck.isChecked())
self.progressBar.setVisible(self.batchCheck.isChecked())
self.inSelector.setType(self.inSelector.FILE if self.batchCheck.isChecked() else self.inSelector.FILE_LAYER)
self.outSelector.clear()
if self.batchCheck.isChecked():
self.inFileLabel = self.label.text()
self.outFileLabel = self.label_2.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
self.label_2.setText(QCoreApplication.translate("GdalTools", "&Output directory"))
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
else:
self.label.setText(self.inFileLabel)
self.label_2.setText(self.outFileLabel)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
QObject.disconnect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputDir)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFile)
QObject.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
def onLayersChanged(self):
self.inSelector.setLayers(Utils.LayerRegistry.instance().getRasterLayers())
self.maskSelector.setLayers(filter(lambda x: x.geometryType() == QGis.Polygon, Utils.LayerRegistry.instance().getVectorLayers()))
def fillInputFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the input file for Warp"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if not inputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(inputFile)
# get SRS for source file if necessary and possible
self.refreshSourceSRS()
def fillOutputFileEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select the raster file to save the results to"), Utils.FileFilter.saveRastersFilter(), lastUsedFilter)
if not outputFile:
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.outputFormat = Utils.fillRasterOutputFormat(lastUsedFilter, outputFile)
self.outSelector.setFilename(outputFile)
def fillMaskFile(self):
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
maskFile = Utils.FileDialog.getOpenFileName(self, self.tr("Select the mask file"), Utils.FileFilter.allVectorsFilter(), lastUsedFilter)
if not maskFile:
return
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
self.maskSelector.setFilename(maskFile)
def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files to Warp"))
if not inputDir:
return
self.inSelector.setFilename(inputDir)
filter = Utils.getRasterExtensions()
workDir = QDir(inputDir)
workDir.setFilter(QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot)
workDir.setNameFilters(filter)
if len(workDir.entryList()) > 0:
fl = inputDir + "/" + workDir.entryList()[0]
self.sourceSRSEdit.setText(Utils.getRasterSRS(self, fl))
def fillOutputDir(self):
outputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the output directory to save the results to"))
if not outputDir:
return
self.outSelector.setFilename(outputDir)
def fillSourceSRSEdit(self):
dialog = SRSDialog("Select the source SRS", self)
if dialog.exec_():
self.sourceSRSEdit.setText(dialog.getProjection())
def fillSourceSRSEditDefault(self):
if self.inSelector.layer() is None:
return
self.refreshSourceSRS()
def refreshSourceSRS(self):
crs = Utils.getRasterSRS(self, self.getInputFileName())
self.sourceSRSEdit.setText(crs)
self.sourceSRSCheck.setChecked(crs != '')
def fillTargetSRSEdit(self):
dialog = SRSDialog("Select the target SRS", self)
if dialog.exec_():
self.targetSRSEdit.setText(dialog.getProjection())
def getArguments(self):
arguments = []
if not self.isBatchEnabled():
arguments.append("-overwrite")
if self.sourceSRSCheck.isChecked() and self.sourceSRSEdit.text():
arguments.append("-s_srs")
arguments.append(self.sourceSRSEdit.text())
if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text():
arguments.append("-t_srs")
arguments.append(self.targetSRSEdit.text())
if self.resamplingCheck.isChecked() and self.resamplingCombo.currentIndex() >= 0:
arguments.append("-r")
arguments.append(self.resampling_method[self.resamplingCombo.currentIndex()])
if self.cacheCheck.isChecked():
arguments.append("-wm")
arguments.append(unicode(self.cacheSpin.value()))
if self.resizeGroupBox.isChecked():
arguments.append("-ts")
arguments.append(unicode(self.widthSpin.value()))
arguments.append(unicode(self.heightSpin.value()))
if self.multithreadCheck.isChecked():
arguments.append("-multi")
if self.noDataCheck.isChecked():
nodata = self.noDataEdit.text().strip()
if nodata:
arguments.append("-dstnodata")
arguments.append(nodata)
if self.maskCheck.isChecked():
mask = self.getMaskFileName()
if mask:
arguments.append("-q")
arguments.append("-cutline")
arguments.append(mask)
arguments.append("-dstalpha")
if self.isBatchEnabled():
return arguments
outputFn = self.getOutputFileName()
if outputFn:
arguments.append("-of")
arguments.append(self.outputFormat)
arguments.append(self.getInputFileName())
arguments.append(outputFn)
return arguments
def getInputFileName(self):
return self.inSelector.filename()
def getOutputFileName(self):
return self.outSelector.filename()
def getMaskFileName(self):
return self.maskSelector.filename()
def addLayerIntoCanvas(self, fileInfo):
self.iface.addRasterLayer(fileInfo.filePath())
def isBatchEnabled(self):
return self.batchCheck.isChecked()
def setProgressRange(self, maximum):
self.progressBar.setRange(0, maximum)
def updateProgress(self, index, total):
if index < total:
self.progressBar.setValue(index + 1)
else:
self.progressBar.setValue(0)

View File

@ -1,204 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
extentSelector.py
---------------------
Date : December 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'December 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget, QColor
from qgis.core import QgsPoint, QgsRectangle, QGis
from qgis.gui import QgsMapTool, QgsMapToolEmitPoint, QgsRubberBand
from ui_extentSelector import Ui_GdalToolsExtentSelector as Ui_ExtentSelector
class GdalToolsExtentSelector(QWidget, Ui_ExtentSelector):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.canvas = None
self.tool = None
self.previousMapTool = None
self.isStarted = False
self.setupUi(self)
self.connect(self.x1CoordEdit, SIGNAL("textChanged(const QString &)"), self.coordsChanged)
self.connect(self.x2CoordEdit, SIGNAL("textChanged(const QString &)"), self.coordsChanged)
self.connect(self.y1CoordEdit, SIGNAL("textChanged(const QString &)"), self.coordsChanged)
self.connect(self.y2CoordEdit, SIGNAL("textChanged(const QString &)"), self.coordsChanged)
self.connect(self.btnEnable, SIGNAL("clicked()"), self.start)
def setCanvas(self, canvas):
self.canvas = canvas
self.tool = RectangleMapTool(self.canvas)
self.previousMapTool = self.canvas.mapTool()
self.connect(self.tool, SIGNAL("rectangleCreated()"), self.fillCoords)
self.connect(self.tool, SIGNAL("deactivated()"), self.pause)
def stop(self):
if not self.isStarted:
return
self.isStarted = False
self.btnEnable.setVisible(False)
self.tool.reset()
self.canvas.unsetMapTool(self.tool)
if self.previousMapTool != self.tool:
self.canvas.setMapTool(self.previousMapTool)
#self.coordsChanged()
self.emit(SIGNAL("selectionStopped()"))
def start(self):
prevMapTool = self.canvas.mapTool()
if prevMapTool != self.tool:
self.previousMapTool = prevMapTool
self.canvas.setMapTool(self.tool)
self.isStarted = True
self.btnEnable.setVisible(False)
self.coordsChanged()
self.emit(SIGNAL("selectionStarted()"))
def pause(self):
if not self.isStarted:
return
self.btnEnable.setVisible(True)
self.emit(SIGNAL("selectionPaused()"))
def setExtent(self, rect):
if self.tool.setRectangle(rect):
self.emit(SIGNAL("newExtentDefined()"))
def getExtent(self):
return self.tool.rectangle()
def isCoordsValid(self):
try:
QgsPoint(float(self.x1CoordEdit.text()), float(self.y1CoordEdit.text()))
QgsPoint(float(self.x2CoordEdit.text()), float(self.y2CoordEdit.text()))
except ValueError:
return False
return True
def coordsChanged(self):
rect = None
if self.isCoordsValid():
point1 = QgsPoint(float(self.x1CoordEdit.text()), float(self.y1CoordEdit.text()))
point2 = QgsPoint(float(self.x2CoordEdit.text()), float(self.y2CoordEdit.text()))
rect = QgsRectangle(point1, point2)
self.setExtent(rect)
def fillCoords(self):
rect = self.getExtent()
self.blockSignals(True)
if rect is not None:
self.x1CoordEdit.setText(unicode(rect.xMinimum()))
self.x2CoordEdit.setText(unicode(rect.xMaximum()))
self.y1CoordEdit.setText(unicode(rect.yMaximum()))
self.y2CoordEdit.setText(unicode(rect.yMinimum()))
else:
self.x1CoordEdit.clear()
self.x2CoordEdit.clear()
self.y1CoordEdit.clear()
self.y2CoordEdit.clear()
self.blockSignals(False)
self.emit(SIGNAL("newExtentDefined()"))
class RectangleMapTool(QgsMapToolEmitPoint):
def __init__(self, canvas):
self.canvas = canvas
QgsMapToolEmitPoint.__init__(self, self.canvas)
self.rubberBand = QgsRubberBand(self.canvas, QGis.Polygon)
self.rubberBand.setColor(QColor(255, 0, 0, 100))
self.rubberBand.setWidth(2)
self.reset()
def reset(self):
self.startPoint = self.endPoint = None
self.isEmittingPoint = False
self.rubberBand.reset(QGis.Polygon)
def canvasPressEvent(self, e):
self.startPoint = self.toMapCoordinates(e.pos())
self.endPoint = self.startPoint
self.isEmittingPoint = True
self.showRect(self.startPoint, self.endPoint)
def canvasReleaseEvent(self, e):
self.isEmittingPoint = False
#if self.rectangle() != None:
# self.emit( SIGNAL("rectangleCreated()") )
self.emit(SIGNAL("rectangleCreated()"))
def canvasMoveEvent(self, e):
if not self.isEmittingPoint:
return
self.endPoint = self.toMapCoordinates(e.pos())
self.showRect(self.startPoint, self.endPoint)
def showRect(self, startPoint, endPoint):
self.rubberBand.reset(QGis.Polygon)
if startPoint.x() == endPoint.x() or startPoint.y() == endPoint.y():
return
point1 = QgsPoint(startPoint.x(), startPoint.y())
point2 = QgsPoint(startPoint.x(), endPoint.y())
point3 = QgsPoint(endPoint.x(), endPoint.y())
point4 = QgsPoint(endPoint.x(), startPoint.y())
self.rubberBand.addPoint(point1, False)
self.rubberBand.addPoint(point2, False)
self.rubberBand.addPoint(point3, False)
self.rubberBand.addPoint(point4, True) # true to update canvas
self.rubberBand.show()
def rectangle(self):
if self.startPoint is None or self.endPoint is None:
return None
elif self.startPoint.x() == self.endPoint.x() or self.startPoint.y() == self.endPoint.y():
return None
return QgsRectangle(self.startPoint, self.endPoint)
def setRectangle(self, rect):
if rect == self.rectangle():
return False
if rect is None:
self.reset()
else:
self.startPoint = QgsPoint(rect.xMaximum(), rect.yMaximum())
self.endPoint = QgsPoint(rect.xMinimum(), rect.yMinimum())
self.showRect(self.startPoint, self.endPoint)
return True
def deactivate(self):
QgsMapTool.deactivate(self)
self.emit(SIGNAL("deactivated()"))

View File

@ -1,105 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsExtentSelector</class>
<widget class="QWidget" name="GdalToolsExtentSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>343</width>
<height>134</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Select the extent by drag on canvas</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>or change the extent coordinates</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="x1CoordEdit"/>
</item>
<item row="0" column="7">
<widget class="QLabel" name="label_13">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QLineEdit" name="x2CoordEdit"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="y1CoordEdit"/>
</item>
<item row="1" column="8">
<widget class="QLineEdit" name="y2CoordEdit"/>
</item>
<item row="1" column="7">
<widget class="QLabel" name="label_15">
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_14">
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item row="0" column="6" rowspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>2</string>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="btnEnable">
<property name="text">
<string>Re-Enable</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,259 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
inOutSelector.py
---------------------
Date : April 2011
Copyright : (C) 2011 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'April 2011'
__copyright__ = '(C) 2011, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, Qt, pyqtProperty
from PyQt4.QtGui import QWidget, QComboBox
from qgis.core import QgsMapLayerRegistry, QgsMapLayer
from ui_inOutSelector import Ui_GdalToolsInOutSelector
class GdalToolsInOutSelector(QWidget, Ui_GdalToolsInOutSelector):
FILE = 0x1
LAYER = 0x2
MULTIFILE = 0x4 # NOT IMPLEMENTED YET
FILE_LAYER = 0x1 | 0x2
FILES = 0x1 | 0x4 # NOT IMPLEMENTED YET
FILES_LAYER = 0x3 | 0x4 # NOT IMPLEMENTED YET
__pyqtSignals__ = ("selectClicked()", "filenameChanged(), layerChanged()")
def __init__(self, parent=None, type=None):
QWidget.__init__(self, parent)
self.setupUi(self)
self.setFocusPolicy(Qt.StrongFocus)
self.combo.setInsertPolicy(QComboBox.NoInsert)
self.clear()
self.typ = None
if type is None:
self.resetType()
else:
self.setType(type)
self.connect(self.selectBtn, SIGNAL("clicked()"), self.selectButtonClicked)
self.connect(self.fileEdit, SIGNAL("textChanged(const QString &)"), self.textChanged)
self.connect(self.combo, SIGNAL("editTextChanged(const QString &)"), self.textChanged)
self.connect(self.combo, SIGNAL("currentIndexChanged(int)"), self.indexChanged)
def clear(self):
self.filenames = []
self.fileEdit.clear()
self.clearComboState()
self.combo.clear()
def textChanged(self):
if self.getType() & self.MULTIFILE:
self.filenames = self.fileEdit.text().split(",")
if self.getType() & self.LAYER:
index = self.combo.currentIndex()
if index >= 0:
text = self.combo.currentText()
if text != self.combo.itemText(index):
return self.setFilename(text)
self.filenameChanged()
def indexChanged(self):
self.layerChanged()
self.filenameChanged()
def selectButtonClicked(self):
self.emit(SIGNAL("selectClicked()"))
def filenameChanged(self):
self.emit(SIGNAL("filenameChanged()"))
def layerChanged(self):
self.emit(SIGNAL("layerChanged()"))
def setType(self, type):
if type == self.typ:
return
if type & self.MULTIFILE: # MULTITYPE IS NOT IMPLEMENTED YET
type = type & ~self.MULTIFILE
self.typ = type
self.selectBtn.setVisible(self.getType() & self.FILE)
self.combo.setVisible(self.getType() & self.LAYER)
self.fileEdit.setVisible(not (self.getType() & self.LAYER))
self.combo.setEditable(self.getType() & self.FILE)
if self.getType() & self.FILE:
self.setFocusProxy(self.selectBtn)
else:
self.setFocusProxy(self.combo)
# send signals to refresh connected widgets
self.filenameChanged()
self.layerChanged()
def getType(self):
return self.typ
def resetType(self):
self.setType(self.FILE_LAYER)
selectorType = pyqtProperty("int", getType, setType, resetType)
def setFilename(self, fn=None):
self.blockSignals(True)
prevFn, prevLayer = self.filename(), self.layer()
if isinstance(fn, QgsMapLayer):
fn = fn.source()
elif isinstance(fn, str) or isinstance(fn, unicode):
fn = unicode(fn)
# TODO test
elif isinstance(fn, list):
if len(fn) > 0:
if self.getType() & self.MULTIFILE:
self.filenames = fn
#fn = "".join( fn, "," )
fn = ",".join(fn)
else:
fn = ''
else:
fn = ''
if not (self.getType() & self.LAYER):
self.fileEdit.setText(fn)
else:
self.combo.setCurrentIndex(-1)
self.combo.setEditText(fn)
self.blockSignals(False)
if self.filename() != prevFn:
self.filenameChanged()
if self.layer() != prevLayer:
self.layerChanged()
def setLayer(self, layer=None):
if not (self.getType() & self.LAYER):
return self.setFilename(layer)
self.blockSignals(True)
prevFn, prevLayer = self.filename(), self.layer()
if isinstance(layer, QgsMapLayer):
if self.combo.findData(layer.id()) >= 0:
index = self.combo.findData(layer.id())
self.combo.setCurrentIndex(index)
else:
self.combo.setCurrentIndex(-1)
self.combo.setEditText(layer.source())
elif isinstance(layer, int) and layer >= 0 and layer < self.combo.count():
self.combo.setCurrentIndex(layer)
else:
self.combo.clearEditText()
self.combo.setCurrentIndex(-1)
self.blockSignals(False)
if self.filename() != prevFn:
self.filenameChanged()
if self.layer() != prevLayer:
self.layerChanged()
def setLayers(self, layers=None):
if layers is None or not hasattr(layers, '__iter__') or len(layers) <= 0:
self.combo.clear()
return
self.blockSignals(True)
prevFn, prevLayer = self.filename(), self.layer()
self.saveComboState()
self.combo.clear()
for l in layers:
self.combo.addItem(l.name(), l.id())
self.restoreComboState()
self.blockSignals(False)
if self.filename() != prevFn:
self.filenameChanged()
if self.layer() != prevLayer:
self.layerChanged()
def clearComboState(self):
self.prevState = None
def saveComboState(self):
index = self.combo.currentIndex()
text = self.combo.currentText()
layerID = self.combo.itemData(index) if index >= 0 else ""
self.prevState = (index, text, layerID)
def restoreComboState(self):
if self.prevState is None:
return
index, text, layerID = self.prevState
if index < 0:
if text == '' and self.combo.count() > 0:
index = 0
elif self.combo.findData(layerID) < 0:
index = -1
text = ""
else:
index = self.combo.findData(layerID)
self.combo.setCurrentIndex(index)
if index >= 0:
text = self.combo.itemText(index)
self.combo.setEditText(text)
def layer(self):
if self.getType() != self.FILE and self.combo.currentIndex() >= 0:
layerID = self.combo.itemData(self.combo.currentIndex())
return QgsMapLayerRegistry.instance().mapLayer(layerID)
return None
def filename(self):
if not (self.getType() & self.LAYER):
if self.getType() & self.MULTIFILE:
return self.filenames
return self.fileEdit.text()
if self.combo.currentIndex() < 0:
if self.getType() & self.MULTIFILE:
return self.filenames
return self.combo.currentText()
layer = self.layer()
if layer is not None:
return layer.source()
return ''

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsInOutSelector</class>
<widget class="QWidget" name="GdalToolsInOutSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>294</width>
<height>28</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="fileEdit">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectBtn">
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,79 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
optionsTable.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QWidget, QTableWidgetItem
from ui_optionsTable import Ui_GdalToolsOptionsTable as Ui_OptionsTable
class GdalToolsOptionsTable(QWidget, Ui_OptionsTable):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setupUi(self)
self.connect(self.table, SIGNAL("cellChanged(int, int)"), SIGNAL("cellValueChanged(int, int)"))
self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.enableDeleteButton)
self.connect(self.btnAdd, SIGNAL("clicked()"), self.addNewRow)
self.connect(self.btnDel, SIGNAL("clicked()"), self.deleteRow)
self.btnDel.setEnabled(False)
def enableDeleteButton(self):
self.btnDel.setEnabled(self.table.currentRow() >= 0)
def addNewRow(self):
self.table.insertRow(self.table.rowCount())
# select the added row
newRow = self.table.rowCount() - 1
item = QTableWidgetItem()
self.table.setItem(newRow, 0, item)
self.table.setCurrentItem(item)
self.emit(SIGNAL("rowAdded(int)"), newRow)
def deleteRow(self):
if self.table.currentRow() >= 0:
self.table.removeRow(self.table.currentRow())
# select the previous row or the next one if there is no previous row
item = self.table.item(self.table.currentRow(), 0)
self.table.setCurrentItem(item)
self.emit(SIGNAL("rowRemoved()"))
def options(self):
options = []
for row in range(0, self.table.rowCount()):
name = self.table.item(row, 0)
if not name:
continue
value = self.table.item(row, 1)
if not value:
continue
options.append(name.text() + "=" + value.text())
return options

View File

@ -1,99 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsOptionsTable</class>
<widget class="QWidget" name="GdalToolsOptionsTable">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>297</width>
<height>90</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="creationOptionsWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTableWidget" name="table">
<property name="minimumSize">
<size>
<width>204</width>
<height>0</height>
</size>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>30</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>30</number>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnDel">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,18 +0,0 @@
-11000 0 0 0
-500 0 0 30
-100 0 0 200
-1 150 150 255
0 0 120 0
100 0 150 0
270 90 165 90
300 90 175 90
500 50 180 50
500 70 170 70
1000 70 145 75
1000 70 155 75
2000 150 156 100
2800 220 220 220
3000 255 255 255
8850 255 255 255
nv white

View File

@ -1,162 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
widgetBatchBase.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import Qt, QFile, QFileInfo
from PyQt4.QtGui import QMessageBox, QErrorMessage
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
import GdalTools_utils as Utils
class GdalToolsBaseBatchWidget(BasePluginWidget):
def __init__(self, iface, commandName):
BasePluginWidget.__init__(self, iface, commandName)
def getBatchArguments(self, inFile, outFile=None):
arguments = []
arguments.extend(self.getArguments())
arguments.append(inFile)
if outFile is not None:
arguments.append(outFile)
return arguments
def isBatchEnabled(self):
return False
def isRecursiveScanEnabled(self):
return False
def setProgressRange(self, maximum):
pass
def updateProgress(self, value, maximum):
pass
def getBatchOutputFileName(self, fn):
inDir = self.getInputFileName()
outDir = self.getOutputFileName()
# if overwrites existent files
if outDir is None or outDir == inDir:
return fn + ".tmp"
return outDir + fn[len(inDir):]
def onRun(self):
if not self.isBatchEnabled():
BasePluginWidget.onRun(self)
return
self.batchRun()
def batchRun(self):
self.inFiles = Utils.getRasterFiles(self.getInputFileName(), self.isRecursiveScanEnabled())
if len(self.inFiles) == 0:
QMessageBox.warning(self, self.tr("Warning"), self.tr("No input files to process."))
return
self.outFiles = []
for f in self.inFiles:
self.outFiles.append(self.getBatchOutputFileName(f))
self.base.enableRun(False)
self.base.setCursor(Qt.WaitCursor)
self.errors = []
self.batchIndex = 0
self.batchTotal = len(self.inFiles)
self.setProgressRange(self.batchTotal)
self.runItem(self.batchIndex, self.batchTotal)
def runItem(self, index, total):
self.updateProgress(index, total)
if index >= total:
self.batchFinished()
return
outFile = None
if len(self.outFiles) > index:
outFile = self.outFiles[index]
args = self.getBatchArguments(self.inFiles[index], outFile)
self.base.refreshArgs(args)
BasePluginWidget.onRun(self)
def onFinished(self, exitCode, status):
if not self.isBatchEnabled():
BasePluginWidget.onFinished(self, exitCode, status)
return
msg = bytes.decode(bytes(self.base.process.readAllStandardError()))
if msg != '':
self.errors.append(">> " + self.inFiles[self.batchIndex] + "<br>" + msg.replace("\n", "<br>"))
self.base.process.close()
# overwrite existent files
inDir = self.getInputFileName()
outDir = self.getOutputFileName()
if outDir is None or inDir == outDir:
oldFile = QFile(self.inFiles[self.batchIndex])
newFile = QFile(self.outFiles[self.batchIndex])
if oldFile.remove():
newFile.rename(self.inFiles[self.batchIndex])
self.batchIndex += 1
self.runItem(self.batchIndex, self.batchTotal)
def batchFinished(self):
self.base.stop()
if len(self.errors) > 0:
msg = u"Processing of the following files ended with error: <br><br>" + "<br><br>".join(self.errors)
QErrorMessage(self).showMessage(msg)
inDir = self.getInputFileName()
outDir = self.getOutputFileName()
if outDir is None or inDir == outDir:
self.outFiles = self.inFiles
# load layers managing the render flag to avoid waste of time
canvas = self.iface.mapCanvas()
previousRenderFlag = canvas.renderFlag()
canvas.setRenderFlag(False)
notCreatedList = []
for item in self.outFiles:
fileInfo = QFileInfo(item)
if fileInfo.exists():
if self.base.loadCheckBox.isChecked():
self.addLayerIntoCanvas(fileInfo)
else:
notCreatedList.append(item)
canvas.setRenderFlag(previousRenderFlag)
if len(notCreatedList) == 0:
QMessageBox.information(self, self.tr("Finished"), self.tr("Operation completed."))
else:
QMessageBox.warning(self, self.tr("Warning"), self.tr("The following files were not created: \n{0}").format(', '.join(notCreatedList)))

View File

@ -1,173 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>348</width>
<height>304</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Build Virtual Raster (Catalog)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="allowProjDiffCheck">
<property name="text">
<string>Allow projection difference</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input files</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="separateCheck">
<property name="text">
<string>Se&amp;parate</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="inputDirCheck">
<property name="text">
<string>Choose input directory instead of files</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="targetSRSCheck">
<property name="text">
<string>Target SRS</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="inputSelLayersCheck">
<property name="text">
<string>Use visible raster layers for input</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="resolutionCheck">
<property name="text">
<string>&amp;Resolution</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="resolutionComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Highest</string>
</property>
</item>
<item>
<property name="text">
<string>Average</string>
</property>
</item>
<item>
<property name="text">
<string>Lowest</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="srcNoDataCheck">
<property name="text">
<string>&amp;Source No Data</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="targetSRSEdit"/>
</item>
<item>
<widget class="QPushButton" name="selectTargetSRSButton">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="noDataEdit">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,356 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>330</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Clipper</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Input file (raster)</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="noDataSpin">
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="noDataCheck">
<property name="text">
<string>&amp;No data value</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="extentGroup">
<property name="title">
<string>Clipping mode</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QStackedWidget" name="modeStackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="GdalToolsExtentSelector" name="extentSelector" native="true"/>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="alphaBandCheck">
<property name="text">
<string>Create an output alpha band</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="maskSelector" native="true"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Mask layer</string>
</property>
</widget>
</item>
<item row="3" column="0" rowspan="5" colspan="2">
<widget class="QGroupBox" name="resolutionGroup">
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QWidget" name="resolutionWidget" native="true">
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>X Resolution</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="xRes">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>12.500000000000000</double>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Y Resolution</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="yRes">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>12.500000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="setResolutionRadio">
<property name="text">
<string>Set output file resolution</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="keepResolutionRadio">
<property name="text">
<string>Keep resolution of input raster</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="10" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="cropToCutlineCheck">
<property name="text">
<string>Crop the extent of the target dataset to the extent of the cutline</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="extentModeRadio">
<property name="text">
<string>Extent</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="maskModeRadio">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Mask layer</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GdalToolsExtentSelector</class>
<extends>QWidget</extends>
<header>extentSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,144 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>520</width>
<height>163</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Contour</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file (raster)</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file for contour lines (vector)</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>I&amp;nterval between contour lines</string>
</property>
<property name="buddy">
<cstring>intervalDSpinBox</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="intervalDSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>2140000000.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="attributeCheck">
<property name="text">
<string>&amp;Attribute name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>If not provided, no elevation attribute is attached.</string>
</property>
<property name="indent">
<number>16</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="attributeEdit">
<property name="text">
<string>ELEV</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,109 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>356</width>
<height>191</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Convert RGB image to paletted</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="batchCheck">
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="colorsCheck">
<property name="text">
<string>Number of colors</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="colorsSpin">
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>256</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="bandSpin">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>256</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="bandCheck">
<property name="text">
<string>Band to convert</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="progressBar"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,478 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>478</width>
<height>404</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>DEM (Terrain models)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>5</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file (DEM raster)</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="bandCheck">
<property name="text">
<string>&amp;Band</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="bandSpin">
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="computeEdgesCheck">
<property name="text">
<string>Compute &amp;edges</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="algorithmCheck">
<property name="text">
<string>Use Zevenbergen&amp;&amp;Thorne formula (instead of the Horn's one)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Mode</string>
</property>
<property name="buddy">
<cstring>modeCombo</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="modeCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Hillshade</string>
</property>
</item>
<item>
<property name="text">
<string>Slope</string>
</property>
</item>
<item>
<property name="text">
<string>Aspect</string>
</property>
</item>
<item>
<property name="text">
<string>Color relief</string>
</property>
</item>
<item>
<property name="text">
<string>TRI (Terrain Ruggedness Index)</string>
</property>
</item>
<item>
<property name="text">
<string>TPI (Topographic Position Index)</string>
</property>
</item>
<item>
<property name="text">
<string>Roughness</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Mode Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Z factor (vertical exaggeration)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="hillshadeZFactorSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>100000000.0</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Scale (ratio of vert. units to horiz.)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="hillshadeScaleSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Azimuth of the light</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="hillshadeAzimuthSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>359.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Altitude of the light</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="hillshadeAltitudeSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>359.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="slopePercentCheck">
<property name="text">
<string>Slope expressed as percent (instead of as degrees)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Scale (ratio of vert. units to horiz.)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="slopeScaleSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="aspectTrigonometricCheck">
<property name="text">
<string>Return trigonometric angle (instead of azimuth)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="aspectZeroForFlatCheck">
<property name="text">
<string>Return 0 for flat (instead of -9999)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_4">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Color configuration file</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="colorMatchGroupBox">
<property name="title">
<string>Matching mode</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QRadioButton" name="colorExactRadio">
<property name="text">
<string>Exact color (otherwise &quot;0,0,0,0&quot; RGBA)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="colorNearestRadio">
<property name="text">
<string>Nearest color</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="colorAlphaCheck">
<property name="text">
<string>Add alpha channel</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="configSelector" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_5"/>
<widget class="QWidget" name="page_6"/>
<widget class="QWidget" name="page_7"/>
</widget>
</item>
</layout>
<zorder>modeCombo</zorder>
<zorder>stackedWidget</zorder>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="creationOptionsGroupBox"><property name="collapsed" stdset="0"><bool>false</bool></property><property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>&amp;Creation Options</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<item>
<widget class="QgsRasterFormatSaveOptionsWidget" name="creationOptionsWidget" native="true">
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsRasterFormatSaveOptionsWidget</class>
<extends>QWidget</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>modeCombo</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>282</x>
<y>201</y>
</hint>
<hint type="destinationlabel">
<x>208</x>
<y>310</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Fill Nodata</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="batchCheck">
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input Layer</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_1">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="formatLabel">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>Output format</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="formatCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="distanceCheck">
<property name="text">
<string>Search distance</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="distanceSpin">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="smoothCheck">
<property name="text">
<string>Smooth iterations</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="smoothSpin">
<property name="minimum">
<number>0</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="bandCheck">
<property name="text">
<string>Band to operate on</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="bandSpin">
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="maskCheck">
<property name="text">
<string>Validity mask</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="GdalToolsInOutSelector" name="maskSelector" native="true"/>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="nomaskCheck">
<property name="text">
<string>Do not use the default validity mask</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QProgressBar" name="progressBar"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,854 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>777</width>
<height>348</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Grid (Interpolation)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="zfieldCheck">
<property name="text">
<string>&amp;Z Field</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="zfieldCombo"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="algorithmCheck">
<property name="text">
<string>&amp;Algorithm</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="algorithmCombo">
<item>
<property name="text">
<string>Inverse distance to a power</string>
</property>
</item>
<item>
<property name="text">
<string>Moving average</string>
</property>
</item>
<item>
<property name="text">
<string>Nearest neighbor</string>
</property>
</item>
<item>
<property name="text">
<string>Data metrics</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Power</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="invdistPowerSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Smoothing</string>
</property>
<property name="indent">
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="invdistSmothingSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Radius1</string>
</property>
<property name="indent">
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QDoubleSpinBox" name="invdistRadius1Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Radius2</string>
</property>
<property name="indent">
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QDoubleSpinBox" name="invdistRadius2Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Max points</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="invdistMaxPointsSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Min points</string>
</property>
<property name="indent">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="invdistMinPointsSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Angle</string>
</property>
<property name="indent">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QDoubleSpinBox" name="invdistAngleSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>359.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QLabel" name="label_10">
<property name="text">
<string>No data</string>
</property>
<property name="indent">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QDoubleSpinBox" name="invdistNoDataSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Radius1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="averageRadius1Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Radius2</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="averageRadius2Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Angle</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QDoubleSpinBox" name="averageAngleSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>359.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Min points</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="averageMinPointsSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_23">
<property name="text">
<string>No data</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="averageNoDataSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_5">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Radius1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="nearestRadius1Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Radius2</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="nearestRadius2Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Angle</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QDoubleSpinBox" name="nearestAngleSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>359.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_28">
<property name="text">
<string>No data</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="nearestNoDataSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_6">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Metrics</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="datametricsCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Minimum</string>
</property>
</item>
<item>
<property name="text">
<string>Maximum</string>
</property>
</item>
<item>
<property name="text">
<string>Range</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_31">
<property name="text">
<string>Radius1</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="datametricsRadius1Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_29">
<property name="text">
<string>Radius2</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QDoubleSpinBox" name="datametricsRadius2Spin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Angle</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="datametricsAngleSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>359.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_33">
<property name="text">
<string>No data</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="datametricsNoDataSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>65000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_30">
<property name="text">
<string>Min points</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QSpinBox" name="datametricsMinPointsSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="resizeGroupBox">
<property name="title">
<string>Resize</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="widthSpin">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Height</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="heightSpin">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="extentGroup">
<property name="title">
<string>Extent</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="GdalToolsExtentSelector" name="extentSelector" native="true"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GdalToolsExtentSelector</class>
<extends>QWidget</extends>
<header>extentSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>algorithmCombo</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>159</x>
<y>129</y>
</hint>
<hint type="destinationlabel">
<x>159</x>
<y>290</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,86 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>426</width>
<height>292</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Info</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Raster info</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="rasterInfoList">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="suppressGCPCheck">
<property name="text">
<string>Suppress GCP printing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="suppressMDCheck">
<property name="text">
<string>Suppress metadata printing</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>371</width>
<height>284</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Merge</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input files</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="noDataCheck">
<property name="text">
<string>&amp;No data value</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="noDataSpin">
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="3" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="inputDirCheck">
<property name="text">
<string>Choose input directory instead of files</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="separateCheck">
<property name="text">
<string>Layer stack</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="intersectCheck">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use intersected extent</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pctCheck">
<property name="text">
<string>Grab pseudocolor table from the first image</string>
</property>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="creationOptionsGroupBox">
<property name="title">
<string>&amp;Creation Options</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QgsRasterFormatSaveOptionsWidget" name="creationOptionsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsRasterFormatSaveOptionsWidget</class>
<extends>QWidget</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,86 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>443</width>
<height>125</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Near Black</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="nearCheck">
<property name="text">
<string>How &amp;far from black (or white)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="nearSpin">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="whiteCheckBox">
<property name="text">
<string>Search for nearly &amp;white (255) pixels instead of black ones</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>376</width>
<height>342</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Build overviews (Pyramids)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="batchCheck">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="cleanCheck">
<property name="toolTip">
<string>Remove all overviews.</string>
</property>
<property name="text">
<string>Clean</string>
</property>
</widget>
</item>
<item>
<widget class="QgsRasterPyramidsOptionsWidget" name="mPyramidOptionsWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsRasterPyramidsOptionsWidget</class>
<extends>QWidget</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,210 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
widgetPluginBase.py
---------------------
Date : June 2010
Copyright : (C) 2010 by Giuseppe Sucameli
Email : brush dot tyler 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__ = 'Giuseppe Sucameli'
__date__ = 'June 2010'
__copyright__ = '(C) 2010, Giuseppe Sucameli'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4.QtCore import SIGNAL, QFileInfo
from PyQt4.QtGui import QWidget, QMessageBox, QAbstractButton, QGroupBox
from dialogBase import GdalToolsBaseDialog as BaseDialog
import GdalTools_utils as Utils
class GdalToolsBasePluginWidget:
def __init__(self, iface, commandName):
self.iface = iface
self.initialized = False
self.base = BaseDialog(iface.mainWindow(), iface, self, self.windowTitle(), commandName)
self.connect(self.base, SIGNAL("processError(QProcess::ProcessError)"), self.onError)
self.connect(self.base, SIGNAL("processFinished(int, QProcess::ExitStatus)"), self.onFinished)
self.connect(self.base, SIGNAL("okClicked()"), self.onRun)
self.connect(self.base, SIGNAL("closeClicked()"), self.onClosing)
self.connect(self.base, SIGNAL("helpClicked()"), self.onHelp)
self.connect(self.base, SIGNAL("finished(bool)"), self.finished)
self.connect(self.base, SIGNAL("refreshArgs()"), self.someValueChanged)
def someValueChanged(self):
if self.initialized:
self.emit(SIGNAL("valuesChanged(PyQt_PyObject)"), self.getArguments())
def onLayersChanged(self):
pass
def initialize(self):
if not self.initialized:
self.connect(Utils.LayerRegistry.instance(), SIGNAL("layersChanged"), self.onLayersChanged)
self.onLayersChanged()
self.initialized = True
self.someValueChanged()
def exec_(self):
self.initialize()
return self.base.exec_()
def show_(self):
self.initialize()
return self.base.show()
def setCommandViewerEnabled(self, enable):
self.base.setCommandViewerEnabled(enable)
self.someValueChanged()
def onRun(self):
self.base.onRun()
def onClosing(self):
self.disconnect(Utils.LayerRegistry.instance(), SIGNAL("layersChanged"), self.onLayersChanged)
self.base.onClosing()
self.initialized = False
def onHelp(self):
self.base.onHelp()
def onFinished(self, exitCode, status):
self.base.onFinished(exitCode, status)
def onError(self, error):
self.base.onError(error)
def getArguments(self):
pass
def getInputFileName(self):
pass
def getOutputFileName(self):
pass
def addLayerIntoCanvas(self, fileInfo):
pass
def finished(self, load):
outFn = self.getOutputFileName()
if outFn is None:
return
if outFn == '':
QMessageBox.warning(self, self.tr("Warning"), self.tr("No output file created."))
return
fileInfo = QFileInfo(outFn)
if fileInfo.exists():
if load:
self.addLayerIntoCanvas(fileInfo)
QMessageBox.information(self, self.tr("Finished"), self.tr("Processing completed."))
else:
#QMessageBox.warning(self, self.tr( "Warning" ), self.tr( "%1 not created." ).arg( outFn ) )
QMessageBox.warning(self, self.tr("Warning"), self.tr("%s not created.") % outFn)
# This method is useful to set up options for the command. It sets for each passed widget:
# 1. its passed signals to connect to the BasePluginWidget.someValueChanged() slot,
# 2. its enabler checkbox or enabled status,
# 3. its status as visible (hide) if the installed gdal version is greater or equal (lesser) then the passed version
#
# wdgts_sgnls_chk_ver_list: list of wdgts_sgnls_chk_ver
# wdgts_sgnls_chk_ver: tuple containing widgets, signals, enabler checkbox or enabled status, required version
def setParamsStatus(self, wdgts_sgnls_chk_ver_list):
if isinstance(wdgts_sgnls_chk_ver_list, list):
for wdgts_sgnls_chk_ver in wdgts_sgnls_chk_ver_list:
self.setParamsStatus(wdgts_sgnls_chk_ver)
return
wdgts_sgnls_chk_ver = wdgts_sgnls_chk_ver_list
if not isinstance(wdgts_sgnls_chk_ver, tuple):
return
if len(wdgts_sgnls_chk_ver) > 0:
wdgts = wdgts_sgnls_chk_ver[0]
else:
wdgts = None
if len(wdgts_sgnls_chk_ver) > 1:
sgnls = wdgts_sgnls_chk_ver[1]
else:
sgnls = None
if len(wdgts_sgnls_chk_ver) > 2:
chk = wdgts_sgnls_chk_ver[2]
else:
chk = None
if len(wdgts_sgnls_chk_ver) > 3:
ver = wdgts_sgnls_chk_ver[3]
else:
ver = None
if isinstance(wdgts, list):
for wdgt in wdgts:
self.setParamsStatus((wdgt, sgnls, chk, ver))
return
wdgt = wdgts
if not isinstance(wdgt, QWidget):
return
# if check version fails, disable the widget then hide both it and its enabler checkbox
# new check for gdal 1.10, must update all widgets for this and then remove previous check
if ver is not None and isinstance(ver, int):
gdalVerNum = Utils.GdalConfig.versionNum()
if ver > gdalVerNum:
wdgt.setVisible(False)
if isinstance(chk, QWidget):
chk.setVisible(False)
chk.setChecked(False)
sgnls = None
chk = False
elif ver is not None:
if not isinstance(ver, Utils.Version):
ver = Utils.Version(ver)
gdalVer = Utils.GdalConfig.version()
if ver < "0" or (gdalVer is not None and ver > gdalVer):
wdgt.setVisible(False)
if isinstance(chk, QWidget):
chk.setVisible(False)
chk.setChecked(False)
sgnls = None
chk = False
# connects the passed signals to the BasePluginWidget.someValueChanged slot
if isinstance(sgnls, list):
for sgnl in sgnls:
self.setParamsStatus((wdgt, sgnl, chk))
return
sgnl = sgnls
if sgnl is not None:
self.connect(wdgt, sgnl, self.someValueChanged)
# set the passed checkbox as widget enabler
if isinstance(chk, bool):
wdgt.setEnabled(chk)
if ( isinstance(chk, QAbstractButton) or isinstance(chk, QGroupBox) ) and \
chk.isCheckable():
wdgt.setEnabled(chk.isChecked())
self.connect(chk, SIGNAL("toggled(bool)"), wdgt.setEnabled)
self.connect(chk, SIGNAL("toggled(bool)"), self.someValueChanged)

View File

@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>446</width>
<height>121</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Polygonize (Raster to vector)</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file (raster)</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file for polygons (shapefile)</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="fieldCheck">
<property name="text">
<string>&amp;Field name</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="fieldEdit">
<property name="text">
<string>DN</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="maskCheck">
<property name="text">
<string>Use mask</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="GdalToolsInOutSelector" name="maskSelector" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,109 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>244</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Assign projection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="batchCheck">
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>WARNING: current projection definition will be cleared</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Desired SRS</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Output will be:
- new GeoTiff if input file is not GeoTiff
- overwritten if input is GeoTiff</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="desiredSRSEdit"/>
</item>
<item>
<widget class="QPushButton" name="selectDesiredSRSButton">
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="progressBar"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,148 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>229</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Proximity (Raster distance)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="valuesCheck">
<property name="text">
<string>&amp;Values</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="distUnitsCheck">
<property name="text">
<string>&amp;Dist units</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="distUnitsCombo">
<item>
<property name="text">
<string>GEO</string>
</property>
</item>
<item>
<property name="text">
<string>PIXEL</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="maxDistCheck">
<property name="text">
<string>&amp;Max dist</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="maxDistSpin">
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="noDataCheck">
<property name="text">
<string>&amp;No data</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="noDataSpin">
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="fixedBufValCheck">
<property name="text">
<string>&amp;Fixed buf val</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="fixedBufValSpin">
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="valuesEdit">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,285 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>509</width>
<height>261</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Rasterize (Vector to raster)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file (shapefile)</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Attribute field</string>
</property>
<property name="buddy">
<cstring>attributeComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="attributeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file for rasterized vectors (raster)</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="radioKeepSize">
<property name="text">
<string>Keep existing raster size and resolution</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioSetSize">
<property name="text">
<string>Raster size in pixels</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widgetSize" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="widthSpin">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelHeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Height</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="heightSpin">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioSetResolution">
<property name="text">
<string>Raster resolution in map units per pixel</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widgetResolution" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelHorizontal">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Horizontal</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="horizresSpin">
<property name="decimals">
<number>8</number>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelVertical">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Vertical</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="vertresSpin">
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
<property name="decimals">
<number>8</number>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>radioSetSize</sender>
<signal>toggled(bool)</signal>
<receiver>widgetSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>254</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>254</x>
<y>163</y>
</hint>
</hints>
</connection>
<connection>
<sender>radioSetResolution</sender>
<signal>toggled(bool)</signal>
<receiver>widgetResolution</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>254</x>
<y>198</y>
</hint>
<hint type="destinationlabel">
<x>254</x>
<y>233</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>365</width>
<height>129</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Sieve</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="thresholdCheck">
<property name="text">
<string>&amp;Threshold</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="thresholdSpin">
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="connectionsCheck">
<property name="text">
<string>&amp;Pixel connections</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="connectionsCombo">
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,90 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>153</height>
</rect>
</property>
<property name="windowTitle">
<string>Raster tile index</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Input directory</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Output shapefile</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="indexFieldCheck">
<property name="text">
<string>Tile index field</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="indexFieldEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>location</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="skipDifferentProjCheck">
<property name="text">
<string>Skip files with different projection ref</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,303 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>335</width>
<height>429</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Translate (Convert format)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="batchCheck">
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Input Layer</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="formatLabel">
<property name="text">
<string>Output format</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="formatCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="targetSRSCheck">
<property name="text">
<string>&amp;Target SRS</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="targetSRSEdit">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectTargetSRSButton">
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="outsizeCheck">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Percentage to resize image. This will change pixel size/image resolution accordingly: 25% will create an image with pixels 4x larger.</string>
</property>
<property name="text">
<string>Outsize</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="outsizeSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Percentage to resize image. This will change pixel size/image resolution accordingly: 25% will create an image with pixels 4x larger.</string>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="nodataCheck">
<property name="toolTip">
<string>Assign a specified nodata value to output bands.</string>
</property>
<property name="text">
<string>No data</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="expandCheck">
<property name="toolTip">
<string>To expose a dataset with 1 band with a color table as a dataset with 3 (RGB) or 4 (RGBA) bands.
Useful for output drivers such as JPEG, JPEG2000, MrSID, ECW that don't support color indexed datasets.
The 'gray' value (from GDAL 1.7.0) enables to expand a dataset with a color table that only contains gray levels to a gray indexed dataset.</string>
</property>
<property name="text">
<string>Expand</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="expandCombo">
<property name="toolTip">
<string>To expose a dataset with 1 band with a color table as a dataset with 3 (RGB) or 4 (RGBA) bands.
Useful for output drivers such as JPEG, JPEG2000, MrSID, ECW that don't support color indexed datasets.
The 'gray' value (from GDAL 1.7.0) enables to expand a dataset with a color table that only contains gray levels to a gray indexed dataset.</string>
</property>
<item>
<property name="text">
<string>Gray</string>
</property>
</item>
<item>
<property name="text">
<string>RGB</string>
</property>
</item>
<item>
<property name="text">
<string>RGBA</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="srcwinCheck">
<property name="toolTip">
<string>Selects a subwindow from the source image for copying based on pixel/line location. (Enter Xoff Yoff Xsize Ysize)</string>
</property>
<property name="text">
<string>Srcwin</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="srcwinEdit">
<property name="toolTip">
<string>Selects a subwindow from the source image for copying based on pixel/line location. (Enter Xoff Yoff Xsize Ysize)</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="prjwinCheck">
<property name="toolTip">
<string>Selects a subwindow from the source image for copying (like -srcwin) but with the corners given in georeferenced coordinates. (Enter ulx uly lrx lry)</string>
</property>
<property name="text">
<string>Prjwin</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="prjwinEdit">
<property name="toolTip">
<string>Selects a subwindow from the source image for copying (like -srcwin) but with the corners given in georeferenced coordinates. (Enter ulx uly lrx lry)</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="sdsCheck">
<property name="toolTip">
<string>Copy all subdatasets of this file to individual output files. Use with formats like HDF or OGDI that have subdatasets.</string>
</property>
<property name="text">
<string>Sds</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="nodataSpin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Assign a specified nodata value to output bands.</string>
</property>
<property name="minimum">
<number>-999999999</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="creationOptionsGroupBox"><property name="collapsed" stdset="0"><bool>false</bool></property><property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
<property name="title">
<string>&amp;Creation Options</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QgsRasterFormatSaveOptionsWidget" name="creationOptionsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsRasterFormatSaveOptionsWidget</class>
<extends>QWidget</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,276 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GdalToolsWidget</class>
<widget class="QWidget" name="GdalToolsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>415</width>
<height>422</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Warp (Reproject)</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="batchCheck">
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Input file</string>
</property>
<property name="buddy">
<cstring>inSelector</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output file</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="sourceSRSCheck">
<property name="text">
<string>&amp;Source SRS</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="sourceSRSEdit">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectSourceSRSButton">
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="targetSRSCheck">
<property name="text">
<string>&amp;Target SRS</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="targetSRSEdit">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectTargetSRSButton">
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="resamplingCheck">
<property name="text">
<string>&amp;Resampling method</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="resamplingCombo">
<item>
<property name="text">
<string>Near</string>
</property>
</item>
<item>
<property name="text">
<string>Bilinear</string>
</property>
</item>
<item>
<property name="text">
<string>Cubic</string>
</property>
</item>
<item>
<property name="text">
<string>Cubic spline</string>
</property>
</item>
<item>
<property name="text">
<string>Lanczos</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="noDataCheck">
<property name="text">
<string>No data values</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="noDataEdit">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="cacheCheck">
<property name="text">
<string>&amp;Memory used for caching</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="cacheSpin">
<property name="suffix">
<string>MB</string>
</property>
<property name="minimum">
<number>20</number>
</property>
<property name="maximum">
<number>1024</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="maskCheck">
<property name="text">
<string>Mask layer</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="1" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="6" column="1">
<widget class="GdalToolsInOutSelector" name="maskSelector" native="true"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="resizeGroupBox">
<property name="title">
<string>Resize</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="widthSpin">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Height</string>
</property>
<property name="indent">
<number>40</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="heightSpin">
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QProgressBar" name="progressBar"/>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="multithreadCheck">
<property name="text">
<string>Use m&amp;ultithreaded warping implementation</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GdalToolsInOutSelector</class>
<extends>QWidget</extends>
<header>inOutSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,12 +0,0 @@
FILE(GLOB INSTALLER_FILES *.py)
FILE(GLOB UI_FILES *.ui)
PYQT_WRAP_UI(PYUI_FILES ${UI_FILES})
PYQT_ADD_RESOURCES(PYRC_FILES resources.qrc)
SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES})
PLUGIN_INSTALL(fTools . ${INSTALLER_FILES} __init__.py metadata.txt)
ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(icons)

View File

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

View File

@ -1,34 +0,0 @@
# -*- coding: utf-8 -*-
#-----------------------------------------------------------
#
# fTools
# Copyright (C) 2008-2011 Carson Farmer
# EMAIL: carson.farmer (at) gmail.com
# WEB : http://www.ftools.ca/fTools.html
#
# A collection of data management and analysis tools for vector data
#
#-----------------------------------------------------------
#
# licensed under the terms of GNU GPL 2
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#---------------------------------------------------------------------
def classFactory(iface):
from .fTools import fToolsPlugin
return fToolsPlugin(iface)

View File

@ -1,495 +0,0 @@
# -*- coding: utf-8 -*-
#-----------------------------------------------------------
#
# fTools
# Copyright (C) 2008-2011 Carson Farmer
# EMAIL: carson.farmer (at) gmail.com
# WEB : http://www.ftools.ca/fTools.html
#
# A collection of data management and analysis tools for vector data
#
#-----------------------------------------------------------
#
# licensed under the terms of GNU GPL 2
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#---------------------------------------------------------------------
from PyQt4.QtCore import QSettings, QDir, QFile, QCoreApplication, QObject, SIGNAL
from PyQt4.QtGui import QIcon, QMessageBox, QMenu, QAction
from qgis.core import QGis
import os.path
import sys
# Set up current path, so that we know where to look for mudules
currentPath = os.path.dirname(__file__)
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/tools'))
# Multi-function modules
import doGeometry
import doGeoprocessing
import doVisual
# Single function modules
# TODO: Eliminate the following modules in favour of above multi-function formats
import doIntersectLines
import doSelectByLocation
import doVectorSplit
import doMeanCoords
import doPointDistance
import doPointsInPolygon
import doRandom
import doRandPoints
import doRegPoints
import doSpatialJoin
import doSubsetSelect
import doSumLines
import doVectorGrid
import doMergeShapes
import doValidate
import doSimplify
import doDefineProj
import doSpatialIndex
import doEliminate
# load icons for actions
import resources_rc
class fToolsPlugin:
def __init__(self, iface):
self.iface = iface
try:
self.QgisVersion = unicode(QGis.QGIS_VERSION_INT)
except:
self.QgisVersion = unicode(QGis.qgisVersion)[0]
def getThemeIcon(self, icon):
settings = QSettings()
pluginPath = os.path.dirname(__file__)
themePath = "icons" + QDir.separator() + settings.value("/Themes", "default") + QDir.separator() + icon
defaultPath = "icons" + QDir.separator() + "default" + QDir.separator() + icon
if QFile.exists(pluginPath + QDir.separator() + themePath):
return QIcon(":" + themePath)
elif QFile.exists(pluginPath + QDir.separator() + defaultPath):
return QIcon(":" + defaultPath)
else:
return QIcon()
def updateThemeIcons(self, theme):
self.analysisMenu.setIcon(QIcon(self.getThemeIcon("analysis.png")))
self.distMatrix.setIcon(QIcon(self.getThemeIcon("matrix.png")))
self.sumLines.setIcon(QIcon(self.getThemeIcon("sum_lines.png")))
self.pointsPoly.setIcon(QIcon(self.getThemeIcon("sum_points.png")))
self.compStats.setIcon(QIcon(self.getThemeIcon("basic_statistics.png")))
self.listUnique.setIcon(QIcon(self.getThemeIcon("unique.png")))
self.nearestNeigh.setIcon(QIcon(self.getThemeIcon("neighbour.png")))
self.meanCoords.setIcon(QIcon(self.getThemeIcon("mean.png")))
self.intLines.setIcon(QIcon(self.getThemeIcon("intersections.png")))
self.researchMenu.setIcon(QIcon(self.getThemeIcon("sampling.png")))
self.randSel.setIcon(QIcon(self.getThemeIcon("random_selection.png")))
self.randSub.setIcon(QIcon(self.getThemeIcon("sub_selection.png")))
self.randPoints.setIcon(QIcon(self.getThemeIcon("random_points.png")))
self.regPoints.setIcon(QIcon(self.getThemeIcon("regular_points.png")))
self.vectGrid.setIcon(QIcon(self.getThemeIcon("vector_grid.png")))
self.selectLocation.setIcon(QIcon(self.getThemeIcon("select_location.png")))
self.layerExtent.setIcon(QIcon(self.getThemeIcon("layer_extent.png")))
self.geoMenu.setIcon(QIcon(self.getThemeIcon("geoprocessing.png")))
self.minConvex.setIcon(QIcon(self.getThemeIcon("convex_hull.png")))
self.dynaBuffer.setIcon(QIcon(self.getThemeIcon("buffer.png")))
self.intersect.setIcon(QIcon(self.getThemeIcon("intersect.png")))
self.union.setIcon(QIcon(self.getThemeIcon("union.png")))
self.symDifference.setIcon(QIcon(self.getThemeIcon("sym_difference.png")))
self.clip.setIcon(QIcon(self.getThemeIcon("clip.png")))
self.dissolve.setIcon(QIcon(self.getThemeIcon("dissolve.png")))
self.erase.setIcon(QIcon(self.getThemeIcon("difference.png")))
self.eliminate.setIcon(QIcon(self.getThemeIcon("eliminate.png")))
self.conversionMenu.setIcon(QIcon(self.getThemeIcon("geometry.png")))
self.compGeo.setIcon(QIcon(self.getThemeIcon("export_geometry.png")))
self.checkGeom.setIcon(QIcon(self.getThemeIcon("check_geometry.png")))
self.centroids.setIcon(QIcon(self.getThemeIcon("centroids.png")))
self.delaunay.setIcon(QIcon(self.getThemeIcon("delaunay.png")))
self.voronoi.setIcon(QIcon(self.getThemeIcon("voronoi.png")))
self.extNodes.setIcon(QIcon(self.getThemeIcon("extract_nodes.png")))
self.simplify.setIcon(QIcon(self.getThemeIcon("simplify.png")))
self.densify.setIcon(QIcon(self.getThemeIcon("densify.png")))
self.multiToSingle.setIcon(QIcon(self.getThemeIcon("multi_to_single.png")))
self.singleToMulti.setIcon(QIcon(self.getThemeIcon("single_to_multi.png")))
self.polysToLines.setIcon(QIcon(self.getThemeIcon("to_lines.png")))
self.linesToPolys.setIcon(QIcon(self.getThemeIcon("to_lines.png")))
self.dataManageMenu.setIcon(QIcon(self.getThemeIcon("management.png")))
self.define.setIcon(QIcon(self.getThemeIcon("define_projection.png")))
self.spatJoin.setIcon(QIcon(self.getThemeIcon("join_location.png")))
self.splitVect.setIcon(QIcon(self.getThemeIcon("split_layer.png")))
self.mergeShapes.setIcon(QIcon(self.getThemeIcon("merge_shapes.png")))
self.spatialIndex.setIcon(QIcon(self.getThemeIcon("spatial_index.png")))
def initGui(self):
if int(self.QgisVersion) < 1:
QMessageBox.warning(
self.iface.getMainWindow(), "fTools",
QCoreApplication.translate("fTools", "QGIS version detected: ") + unicode(self.QgisVersion) + ".xx\n"
+ QCoreApplication.translate("fTools", "This version of fTools requires at least QGIS version 1.0.0\nPlugin will not be enabled."))
return None
QObject.connect(self.iface, SIGNAL("currentThemeChanged (QString)"), self.updateThemeIcons)
self.analysisMenu = QMenu(QCoreApplication.translate("fTools", "&Analysis Tools"))
self.analysisMenu.setObjectName("analysisMenu")
self.distMatrix = QAction(QCoreApplication.translate("fTools", "Distance Matrix..."), self.iface.mainWindow())
self.distMatrix.setObjectName("distMatrix")
self.sumLines = QAction(QCoreApplication.translate("fTools", "Sum Line Lengths..."), self.iface.mainWindow())
self.sumLines.setObjectName("sumLines")
self.pointsPoly = QAction(QCoreApplication.translate("fTools", "Points in Polygon..."), self.iface.mainWindow())
self.pointsPoly.setObjectName("pointsPoly")
self.compStats = QAction(QCoreApplication.translate("fTools", "Basic Statistics..."), self.iface.mainWindow())
self.compStats.setObjectName("compStats")
self.listUnique = QAction(QCoreApplication.translate("fTools", "List Unique Values..."), self.iface.mainWindow())
self.listUnique.setObjectName("listUnique")
self.nearestNeigh = QAction(QCoreApplication.translate("fTools", "Nearest Neighbour Analysis..."), self.iface.mainWindow())
self.nearestNeigh.setObjectName("nearestNeigh")
self.meanCoords = QAction(QCoreApplication.translate("fTools", "Mean Coordinate(s)..."), self.iface.mainWindow())
self.meanCoords.setObjectName("meanCoords")
self.intLines = QAction(QCoreApplication.translate("fTools", "Line Intersections..."), self.iface.mainWindow())
self.intLines.setObjectName("intLines")
self.analysisMenu.addActions([
self.distMatrix, self.sumLines, self.pointsPoly,
self.listUnique, self.compStats, self.nearestNeigh, self.meanCoords, self.intLines])
self.researchMenu = QMenu(QCoreApplication.translate("fTools", "&Research Tools"))
self.researchMenu.setObjectName("researchMenu")
self.randSel = QAction(QCoreApplication.translate("fTools", "Random Selection..."), self.iface.mainWindow())
self.randSel.setObjectName("randSel")
self.randSub = QAction(QCoreApplication.translate("fTools", "Random Selection Within Subsets..."), self.iface.mainWindow())
self.randSub.setObjectName("randSub")
self.randPoints = QAction(QCoreApplication.translate("fTools", "Random Points..."), self.iface.mainWindow())
self.randPoints.setObjectName("randPoints")
self.regPoints = QAction(QCoreApplication.translate("fTools", "Regular Points..."), self.iface.mainWindow())
self.regPoints.setObjectName("regPoints")
self.vectGrid = QAction(QCoreApplication.translate("fTools", "Vector Grid..."), self.iface.mainWindow())
self.vectGrid.setObjectName("vectGrid")
self.selectLocation = QAction(QCoreApplication.translate("fTools", "Select by Location..."), self.iface.mainWindow())
self.selectLocation.setObjectName("selectLocation")
self.layerExtent = QAction(QCoreApplication.translate("fTools", "Polygon from Layer Extent..."), self.iface.mainWindow())
self.layerExtent.setObjectName("layerExtent")
self.researchMenu.addActions([
self.randSel, self.randSub, self.randPoints,
self.regPoints, self.vectGrid, self.selectLocation, self.layerExtent])
self.geoMenu = QMenu(QCoreApplication.translate("fTools", "&Geoprocessing Tools"))
self.geoMenu.setObjectName("geoMenu")
self.minConvex = QAction(QCoreApplication.translate("fTools", "Convex Hull(s)..."), self.iface.mainWindow())
self.minConvex.setObjectName("minConvex")
self.dynaBuffer = QAction(QCoreApplication.translate("fTools", "Buffer(s)..."), self.iface.mainWindow())
self.dynaBuffer.setObjectName("dynaBuffer")
self.intersect = QAction(QCoreApplication.translate("fTools", "Intersect..."), self.iface.mainWindow())
self.intersect.setObjectName("intersect")
self.union = QAction(QCoreApplication.translate("fTools", "Union..."), self.iface.mainWindow())
self.union.setObjectName("union")
self.symDifference = QAction(QCoreApplication.translate("fTools", "Symmetrical Difference..."), self.iface.mainWindow())
self.symDifference.setObjectName("symDifference")
self.clip = QAction(QCoreApplication.translate("fTools", "Clip..."), self.iface.mainWindow())
self.clip.setObjectName("clip")
self.dissolve = QAction(QCoreApplication.translate("fTools", "Dissolve..."), self.iface.mainWindow())
self.dissolve.setObjectName("dissolve")
self.erase = QAction(QCoreApplication.translate("fTools", "Difference..."), self.iface.mainWindow())
self.erase.setObjectName("erase")
self.eliminate = QAction(QCoreApplication.translate("fTools", "Eliminate Sliver Polygons..."), self.iface.mainWindow())
self.eliminate.setObjectName("eliminate")
self.geoMenu.addActions([
self.minConvex, self.dynaBuffer, self.intersect,
self.union, self.symDifference, self.clip, self.erase, self.dissolve,
self.eliminate])
self.conversionMenu = QMenu(QCoreApplication.translate("fTools", "G&eometry Tools"))
self.conversionMenu.setObjectName("conversionMenu")
self.compGeo = QAction(QCoreApplication.translate("fTools", "Export/Add Geometry Columns..."), self.iface.mainWindow())
self.compGeo.setObjectName("compGeo")
self.checkGeom = QAction(QCoreApplication.translate("fTools", "Check Geometry Validity..."), self.iface.mainWindow())
self.checkGeom.setObjectName("checkGeom")
self.centroids = QAction(QCoreApplication.translate("fTools", "Polygon Centroids..."), self.iface.mainWindow())
self.centroids.setObjectName("centroids")
self.delaunay = QAction(QCoreApplication.translate("fTools", "Delaunay Triangulation..."), self.iface.mainWindow())
self.delaunay.setObjectName("delaunay")
self.voronoi = QAction(QCoreApplication.translate("fTools", "Voronoi Polygons..."), self.iface.mainWindow())
self.voronoi.setObjectName("voronoi")
self.extNodes = QAction(QCoreApplication.translate("fTools", "Extract Nodes..."), self.iface.mainWindow())
self.extNodes.setObjectName("extNodes")
self.simplify = QAction(QCoreApplication.translate("fTools", "Simplify Geometries..."), self.iface.mainWindow())
self.simplify.setObjectName("simplify")
self.densify = QAction(QCoreApplication.translate("fTools", "Densify Geometries..."), self.iface.mainWindow())
self.densify.setObjectName("densify")
self.multiToSingle = QAction(QCoreApplication.translate("fTools", "Multipart to Singleparts..."), self.iface.mainWindow())
self.multiToSingle.setObjectName("multiToSingle")
self.singleToMulti = QAction(QCoreApplication.translate("fTools", "Singleparts to Multipart..."), self.iface.mainWindow())
self.singleToMulti.setObjectName("singleToMulti")
self.polysToLines = QAction(QCoreApplication.translate("fTools", "Polygons to Lines..."), self.iface.mainWindow())
self.polysToLines.setObjectName("polysToLines")
self.linesToPolys = QAction(QCoreApplication.translate("fTools", "Lines to Polygons..."), self.iface.mainWindow())
self.linesToPolys.setObjectName("linesToPolys")
self.conversionMenu.addActions([
self.checkGeom, self.compGeo, self.centroids, self.delaunay, self.voronoi,
self.simplify, self.densify, self.multiToSingle, self.singleToMulti, self.polysToLines, self.linesToPolys,
self.extNodes])
self.dataManageMenu = QMenu(QCoreApplication.translate("fTools", "&Data Management Tools"))
self.dataManageMenu.setObjectName("dataManageMenu")
self.define = QAction(QCoreApplication.translate("fTools", "Define Current Projection..."), self.iface.mainWindow())
self.define.setObjectName("define")
self.spatJoin = QAction(QCoreApplication.translate("fTools", "Join Attributes by Location..."), self.iface.mainWindow())
self.spatJoin.setObjectName("spatJoin")
self.splitVect = QAction(QCoreApplication.translate("fTools", "Split Vector Layer..."), self.iface.mainWindow())
self.splitVect.setObjectName("splitVect")
self.mergeShapes = QAction(QCoreApplication.translate("fTools", "Merge Shapefiles to One..."), self.iface.mainWindow())
self.mergeShapes.setObjectName("mergeShapes")
self.spatialIndex = QAction(QCoreApplication.translate("fTools", "Create Spatial Index..."), self.iface.mainWindow())
self.spatialIndex.setObjectName("spatialIndex")
self.dataManageMenu.addActions([self.define, self.spatJoin, self.splitVect, self.mergeShapes, self.spatialIndex])
self.updateThemeIcons("theme")
self.menu = self.iface.vectorMenu()
self.menu.addMenu(self.analysisMenu)
self.menu.addMenu(self.researchMenu)
self.menu.addMenu(self.geoMenu)
self.menu.addMenu(self.conversionMenu)
self.menu.addMenu(self.dataManageMenu)
QObject.connect(self.distMatrix, SIGNAL("triggered()"), self.dodistMatrix)
QObject.connect(self.sumLines, SIGNAL("triggered()"), self.dosumLines)
QObject.connect(self.pointsPoly, SIGNAL("triggered()"), self.dopointsPoly)
QObject.connect(self.compStats, SIGNAL("triggered()"), self.docompStats)
QObject.connect(self.listUnique, SIGNAL("triggered()"), self.dolistUnique)
QObject.connect(self.nearestNeigh, SIGNAL("triggered()"), self.donearestNeigh)
QObject.connect(self.meanCoords, SIGNAL("triggered()"), self.domeanCoords)
QObject.connect(self.intLines, SIGNAL("triggered()"), self.dointLines)
QObject.connect(self.randSel, SIGNAL("triggered()"), self.dorandSel)
QObject.connect(self.randSub, SIGNAL("triggered()"), self.dorandSub)
QObject.connect(self.randPoints, SIGNAL("triggered()"), self.dorandPoints)
QObject.connect(self.regPoints, SIGNAL("triggered()"), self.doregPoints)
QObject.connect(self.vectGrid, SIGNAL("triggered()"), self.dovectGrid)
QObject.connect(self.selectLocation, SIGNAL("triggered()"), self.doselectLocation)
QObject.connect(self.layerExtent, SIGNAL("triggered()"), self.doextent)
QObject.connect(self.minConvex, SIGNAL("triggered()"), self.dominConvex)
QObject.connect(self.intersect, SIGNAL("triggered()"), self.dointersect)
QObject.connect(self.dissolve, SIGNAL("triggered()"), self.dodissolve)
QObject.connect(self.symDifference, SIGNAL("triggered()"), self.dosymdifference)
QObject.connect(self.erase, SIGNAL("triggered()"), self.doerase)
QObject.connect(self.union, SIGNAL("triggered()"), self.dounion)
QObject.connect(self.clip, SIGNAL("triggered()"), self.doclip)
QObject.connect(self.dynaBuffer, SIGNAL("triggered()"), self.dodynaBuffer)
QObject.connect(self.eliminate, SIGNAL("triggered()"), self.doEliminate)
QObject.connect(self.multiToSingle, SIGNAL("triggered()"), self.domultiToSingle)
QObject.connect(self.singleToMulti, SIGNAL("triggered()"), self.dosingleToMulti)
QObject.connect(self.checkGeom, SIGNAL("triggered()"), self.docheckGeom)
QObject.connect(self.simplify, SIGNAL("triggered()"), self.doSimplify)
QObject.connect(self.densify, SIGNAL("triggered()"), self.doDensify)
QObject.connect(self.centroids, SIGNAL("triggered()"), self.docentroids)
QObject.connect(self.delaunay, SIGNAL("triggered()"), self.dodelaunay)
QObject.connect(self.voronoi, SIGNAL("triggered()"), self.dovoronoi)
QObject.connect(self.polysToLines, SIGNAL("triggered()"), self.dopolysToLines)
QObject.connect(self.linesToPolys, SIGNAL("triggered()"), self.dolinesToPolys)
QObject.connect(self.compGeo, SIGNAL("triggered()"), self.docompGeo)
QObject.connect(self.extNodes, SIGNAL("triggered()"), self.doextNodes)
QObject.connect(self.define, SIGNAL("triggered()"), self.dodefine)
QObject.connect(self.spatJoin, SIGNAL("triggered()"), self.dospatJoin)
QObject.connect(self.splitVect, SIGNAL("triggered()"), self.dosplitVect)
QObject.connect(self.mergeShapes, SIGNAL("triggered()"), self.doMergeShapes)
QObject.connect(self.spatialIndex, SIGNAL("triggered()"), self.doSpatIndex)
def unload(self):
self.menu.removeAction(self.analysisMenu.menuAction())
self.menu.removeAction(self.researchMenu.menuAction())
self.menu.removeAction(self.geoMenu.menuAction())
self.menu.removeAction(self.conversionMenu.menuAction())
self.menu.removeAction(self.dataManageMenu.menuAction())
def doSimplify(self):
d = doSimplify.Dialog(self.iface, 1)
d.show()
d.exec_()
def doDensify(self):
d = doSimplify.Dialog(self.iface, 2)
d.show()
d.exec_()
def dopolysToLines(self):
d = doGeometry.GeometryDialog(self.iface, 4)
d.exec_()
def dolinesToPolys(self):
d = doGeometry.GeometryDialog(self.iface, 11)
d.exec_()
def docheckGeom(self):
d = doValidate.ValidateDialog(self.iface)
d.show()
d.exec_()
def domultiToSingle(self):
d = doGeometry.GeometryDialog(self.iface, 2)
d.exec_()
def dosingleToMulti(self):
d = doGeometry.GeometryDialog(self.iface, 1)
d.exec_()
def doselectLocation(self):
d = doSelectByLocation.Dialog(self.iface)
d.exec_()
def domeanCoords(self):
d = doMeanCoords.Dialog(self.iface, 1)
d.exec_()
def dominConvex(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 2)
d.exec_()
def dodynaBuffer(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 1)
d.exec_()
def dointersect(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 5)
d.exec_()
def dodissolve(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 4)
d.exec_()
def doerase(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 3)
d.exec_()
def dosymdifference(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 7)
d.exec_()
def dounion(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 6)
d.exec_()
def doclip(self):
d = doGeoprocessing.GeoprocessingDialog(self.iface, 8)
d.exec_()
def donearestNeigh(self):
d = doVisual.VisualDialog(self.iface, 4)
d.exec_()
def dodistMatrix(self):
d = doPointDistance.Dialog(self.iface)
d.exec_()
def docentroids(self):
d = doGeometry.GeometryDialog(self.iface, 7)
d.exec_()
def dodelaunay(self):
d = doGeometry.GeometryDialog(self.iface, 8)
d.exec_()
def dovoronoi(self):
d = doGeometry.GeometryDialog(self.iface, 10)
d.exec_()
def doextent(self):
d = doGeometry.GeometryDialog(self.iface, 9)
d.exec_()
def dosumLines(self):
d = doSumLines.Dialog(self.iface)
d.exec_()
def dopointsPoly(self):
d = doPointsInPolygon.Dialog(self.iface)
d.show()
d.exec_()
def dorandSel(self):
d = doRandom.Dialog(self.iface)
d.exec_()
def dorandSub(self):
d = doSubsetSelect.Dialog(self.iface)
d.exec_()
def dorandPoints(self):
d = doRandPoints.Dialog(self.iface)
d.exec_()
def doregPoints(self):
d = doRegPoints.Dialog(self.iface)
d.exec_()
def dovectGrid(self):
d = doVectorGrid.Dialog(self.iface)
d.exec_()
def doextNodes(self):
d = doGeometry.GeometryDialog(self.iface, 3)
d.exec_()
def dointLines(self):
d = doIntersectLines.Dialog(self.iface)
d.exec_()
def dosplitVect(self):
d = doVectorSplit.Dialog(self.iface)
d.show()
d.exec_()
def docompGeo(self):
d = doGeometry.GeometryDialog(self.iface, 5)
d.exec_()
def dolistUnique(self):
d = doVisual.VisualDialog(self.iface, 2)
d.exec_()
def docompStats(self):
d = doVisual.VisualDialog(self.iface, 3)
d.exec_()
def dodefine(self):
d = doDefineProj.Dialog(self.iface)
d.exec_()
def dospatJoin(self):
d = doSpatialJoin.Dialog(self.iface)
d.exec_()
def doMergeShapes(self):
d = doMergeShapes.Dialog(self.iface)
d.show()
d.exec_()
def doSpatIndex(self):
d = doSpatialIndex.Dialog(self.iface)
d.show()
d.exec_()
def doEliminate(self):
d = doEliminate.Dialog(self.iface)
d.exec_()

Some files were not shown because too many files have changed in this diff Show More