Skip to content
Permalink
Browse files

[processing] be more flexible with multipoint layers, allow sampling …

…for single part point
  • Loading branch information
nirvn committed Jul 28, 2018
1 parent 3e31a65 commit e19e1dea9d14f94433ffc4d470ce64cf3e0c251f
Showing with 11 additions and 5 deletions.
  1. +11 −5 python/plugins/processing/algs/qgis/RasterSampling.py
@@ -36,6 +36,7 @@
QgsField,
QgsFeatureSink,
QgsRaster,
QgsPointXY,
QgsProcessing,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterString,
@@ -160,13 +161,18 @@ def processAlgorithm(self, parameters, context, feedback):

attrs = i.attributes()

if i.geometry().isMultipart():
raise QgsProcessingException(self.tr('''Impossible to sample data
of a Multipart layer. Please use the Multipart to single part
algorithm to transform the layer.'''))
if i.geometry().isMultipart() and i.geometry().constGet().partCount() > 1:
sink.addFeature(i, QgsFeatureSink.FastInsert)
feedback.setProgress(int(n * total))
feedback.reportError(self.tr('Impossible to sample data of multipart feature {}.').format(i.id()))
continue

# get the feature geometry as point
point = i.geometry().asPoint()
point = QgsPointXY()
if i.geometry().isMultipart():
point = i.geometry().asMultiPoint()[0]
else:
point = i.geometry().asPoint()

# reproject to raster crs
try:

0 comments on commit e19e1de

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