Skip to content

Commit b7ad288

Browse files
committed
Merge pull request #1924 from gioman/processing_add_gdal_tileindex
[processing] add gdal tileindex
2 parents 33c6051 + bf08b7b commit b7ad288

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

python/plugins/processing/algs/gdal/GdalOgrAlgorithmProvider.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
from GridAverage import GridAverage
6565
from GridNearest import GridNearest
6666
from GridDataMetrics import GridDataMetrics
67+
from gdaltindex import gdaltindex
6768

6869
from ogr2ogr import Ogr2Ogr
6970
from ogr2ogrclip import Ogr2OgrClip
@@ -121,7 +122,7 @@ def createAlgsList(self):
121122
sieve(), fillnodata(), ExtractProjection(), gdal2xyz(),
122123
hillshade(), slope(), aspect(), tri(), tpi(), roughness(),
123124
ColorRelief(), GridInvDist(), GridAverage(), GridNearest(),
124-
GridDataMetrics(),
125+
GridDataMetrics(), gdaltindex(),
125126
# ----- OGR tools -----
126127
OgrInfo(), Ogr2Ogr(), Ogr2OgrClip(), Ogr2OgrClipExtent(),
127128
Ogr2OgrToPostGis(), Ogr2OgrToPostGisList(), OgrSql(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
gdaltindex.py
6+
---------------------
7+
Date : February 2015
8+
Copyright : (C) 2015 by Pedro Venancio
9+
Email : pedrongvenancio at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Pedro Venancio'
21+
__date__ = 'February 2015'
22+
__copyright__ = '(C) 2015, Pedro Venancio'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
29+
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
30+
from processing.core.outputs import OutputVector
31+
from processing.core.parameters import ParameterBoolean
32+
from processing.core.parameters import ParameterMultipleInput
33+
from processing.core.parameters import ParameterString
34+
from processing.algs.gdal.GdalUtils import GdalUtils
35+
36+
import os
37+
38+
class gdaltindex(GdalAlgorithm):
39+
40+
INPUT = 'INPUT'
41+
OUTPUT = 'OUTPUT'
42+
FIELD_NAME = 'FIELD_NAME'
43+
PROJ_DIFFERENCE = 'PROJ_DIFFERENCE'
44+
45+
def defineCharacteristics(self):
46+
self.name = 'Tile Index'
47+
self.group = '[GDAL] Miscellaneous'
48+
self.addParameter(ParameterMultipleInput(self.INPUT,
49+
self.tr('Input layers'), ParameterMultipleInput.TYPE_RASTER))
50+
self.addParameter(ParameterString(self.FIELD_NAME,
51+
self.tr('Tile index field'),
52+
'location', optional=True))
53+
self.addParameter(ParameterBoolean(self.PROJ_DIFFERENCE,
54+
self.tr('Skip files with different projection reference'), False))
55+
self.addOutput(OutputVector(gdaltindex.OUTPUT, self.tr('Output layer')))
56+
57+
def processAlgorithm(self, progress):
58+
fieldName = str(self.getParameterValue(self.FIELD_NAME))
59+
60+
arguments = []
61+
if len(fieldName) > 0:
62+
arguments.append('-tileindex')
63+
arguments.append(fieldName)
64+
if self.getParameterValue(gdaltindex.PROJ_DIFFERENCE):
65+
arguments.append('-skip_different_projection')
66+
arguments.append(unicode(self.getOutputValue(gdaltindex.OUTPUT)))
67+
arguments.extend(unicode(self.getParameterValue(gdaltindex.INPUT)).split(';'))
68+
69+
70+
GdalUtils.runGdal(['gdaltindex', GdalUtils.escapeAndJoin(arguments)], progress)

0 commit comments

Comments
 (0)