Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
processing: add gdal tileindex
  • Loading branch information
Giovanni Manghi committed Feb 24, 2015
1 parent 4629205 commit bf08b7b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
Expand Up @@ -64,6 +64,7 @@
from GridAverage import GridAverage
from GridNearest import GridNearest
from GridDataMetrics import GridDataMetrics
from gdaltindex import gdaltindex

from ogr2ogr import Ogr2Ogr
from ogr2ogrclip import Ogr2OgrClip
Expand Down Expand Up @@ -121,7 +122,7 @@ def createAlgsList(self):
sieve(), fillnodata(), ExtractProjection(), gdal2xyz(),
hillshade(), slope(), aspect(), tri(), tpi(), roughness(),
ColorRelief(), GridInvDist(), GridAverage(), GridNearest(),
GridDataMetrics(),
GridDataMetrics(), gdaltindex(),
# ----- OGR tools -----
OgrInfo(), Ogr2Ogr(), Ogr2OgrClip(), Ogr2OgrClipExtent(),
Ogr2OgrToPostGis(), Ogr2OgrToPostGisList(), OgrSql(),
Expand Down
70 changes: 70 additions & 0 deletions python/plugins/processing/algs/gdal/gdaltindex.py
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
gdaltindex.py
---------------------
Date : February 2015
Copyright : (C) 2015 by Pedro Venancio
Email : pedrongvenancio 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__ = 'Pedro Venancio'
__date__ = 'February 2015'
__copyright__ = '(C) 2015, Pedro Venancio'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'


from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.core.outputs import OutputVector
from processing.core.parameters import ParameterBoolean
from processing.core.parameters import ParameterMultipleInput
from processing.core.parameters import ParameterString
from processing.algs.gdal.GdalUtils import GdalUtils

import os

class gdaltindex(GdalAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
FIELD_NAME = 'FIELD_NAME'
PROJ_DIFFERENCE = 'PROJ_DIFFERENCE'

def defineCharacteristics(self):
self.name = 'Tile Index'
self.group = '[GDAL] Miscellaneous'
self.addParameter(ParameterMultipleInput(self.INPUT,
self.tr('Input layers'), ParameterMultipleInput.TYPE_RASTER))
self.addParameter(ParameterString(self.FIELD_NAME,
self.tr('Tile index field'),
'location', optional=True))
self.addParameter(ParameterBoolean(self.PROJ_DIFFERENCE,
self.tr('Skip files with different projection reference'), False))
self.addOutput(OutputVector(gdaltindex.OUTPUT, self.tr('Output layer')))

def processAlgorithm(self, progress):
fieldName = str(self.getParameterValue(self.FIELD_NAME))

arguments = []
if len(fieldName) > 0:
arguments.append('-tileindex')
arguments.append(fieldName)
if self.getParameterValue(gdaltindex.PROJ_DIFFERENCE):
arguments.append('-skip_different_projection')
arguments.append(unicode(self.getOutputValue(gdaltindex.OUTPUT)))
arguments.extend(unicode(self.getParameterValue(gdaltindex.INPUT)).split(';'))


GdalUtils.runGdal(['gdaltindex', GdalUtils.escapeAndJoin(arguments)], progress)

0 comments on commit bf08b7b

Please sign in to comment.