Skip to content

Commit f8339c9

Browse files
committedJul 12, 2018
output column prexif added
1 parent b16b8a7 commit f8339c9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed
 

‎python/plugins/processing/algs/qgis/RasterSampling.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
QgsRaster,
3838
QgsProcessing,
3939
QgsProcessingParameterRasterLayer,
40+
QgsProcessingParameterString,
4041
QgsFields,
4142
QgsProcessingUtils,
4243
QgsProcessingException,
@@ -50,6 +51,7 @@ class RasterSampling(QgisAlgorithm):
5051

5152
INPUT = 'INPUT'
5253
RASTERCOPY = 'RASTERCOPY'
54+
COLUMN_PREFIX = 'COLUMN_PREFIX'
5355
OUTPUT = 'OUTPUT'
5456

5557
def name(self):
@@ -83,6 +85,13 @@ def initAlgorithm(self, config=None):
8385
)
8486
)
8587

88+
self.addParameter(
89+
QgsProcessingParameterString(
90+
self.COLUMN_PREFIX,
91+
self.tr('Output column prefix'), 'rvalue'
92+
)
93+
)
94+
8695
self.addParameter(
8796
QgsProcessingParameterFeatureSink(
8897
self.OUTPUT,
@@ -104,6 +113,12 @@ def processAlgorithm(self, parameters, context, feedback):
104113
context
105114
)
106115

116+
columnPrefix = self.parameterAsString(
117+
parameters,
118+
self.COLUMN_PREFIX,
119+
context
120+
)
121+
107122
if source is None:
108123
raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT))
109124

@@ -113,7 +128,7 @@ def processAlgorithm(self, parameters, context, feedback):
113128
# append field to vector as rasterName_bandCount
114129
for b in range(sampled_rasters.bandCount()):
115130
raster_fields.append(QgsField(
116-
'rvalue_' + str('{}'.format(b + 1)), QVariant.Double
131+
columnPrefix + str('_{}'.format(b + 1)), QVariant.Double
117132
)
118133
)
119134

0 commit comments

Comments
 (0)
Please sign in to comment.