Skip to content

Commit

Permalink
output column prexif added
Browse files Browse the repository at this point in the history
  • Loading branch information
ghtmtt committed Jul 12, 2018
1 parent b16b8a7 commit f8339c9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion python/plugins/processing/algs/qgis/RasterSampling.py
Expand Up @@ -37,6 +37,7 @@
QgsRaster,
QgsProcessing,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterString,
QgsFields,
QgsProcessingUtils,
QgsProcessingException,
Expand All @@ -50,6 +51,7 @@ class RasterSampling(QgisAlgorithm):

INPUT = 'INPUT'
RASTERCOPY = 'RASTERCOPY'
COLUMN_PREFIX = 'COLUMN_PREFIX'
OUTPUT = 'OUTPUT'

def name(self):
Expand Down Expand Up @@ -83,6 +85,13 @@ def initAlgorithm(self, config=None):
)
)

self.addParameter(
QgsProcessingParameterString(
self.COLUMN_PREFIX,
self.tr('Output column prefix'), 'rvalue'
)
)

self.addParameter(
QgsProcessingParameterFeatureSink(
self.OUTPUT,
Expand All @@ -104,6 +113,12 @@ def processAlgorithm(self, parameters, context, feedback):
context
)

columnPrefix = self.parameterAsString(
parameters,
self.COLUMN_PREFIX,
context
)

if source is None:
raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT))

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

Expand Down

0 comments on commit f8339c9

Please sign in to comment.