Skip to content
Permalink
Browse files

output column prexif added

  • Loading branch information
ghtmtt committed Jul 12, 2018
1 parent b16b8a7 commit f8339c9b970da06a5c8dafa2d264e5d60be02e97
Showing with 16 additions and 1 deletion.
  1. +16 −1 python/plugins/processing/algs/qgis/RasterSampling.py
@@ -37,6 +37,7 @@
QgsRaster,
QgsProcessing,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterString,
QgsFields,
QgsProcessingUtils,
QgsProcessingException,
@@ -50,6 +51,7 @@ class RasterSampling(QgisAlgorithm):

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

def name(self):
@@ -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,
@@ -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))

@@ -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
)
)

0 comments on commit f8339c9

Please sign in to comment.
You can’t perform that action at this time.