Skip to content
Permalink
Browse files

[Processing] Fix GDAL Assign Projection: update QgsRasterLayer crs

Even if the projection is assign, the QgsRasterLayer and the QgsRasterDataProvider was not updated.

The fix reloads the QgsRasterDataProvider's data and updates the QgsRasterLayer's crs.

Fixed #37920
  • Loading branch information
rldhont committed Jul 31, 2020
1 parent e19f27d commit 6c44073ff0e30fa36a4ad3a37075002c97b07d4c
Showing with 36 additions and 1 deletion.
  1. +36 −1 python/plugins/processing/algs/gdal/AssignProjection.py
@@ -28,7 +28,8 @@
from qgis.core import (QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterCrs,
QgsProcessingOutputRasterLayer)
QgsProcessingOutputRasterLayer,
QgsProcessingContext)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils

@@ -97,3 +98,37 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
self.setOutputValue(self.OUTPUT, fileName)

return commands

def postProcessAlgorithm(self, context, feedback):
# get output value
fileName = self.output_values.get(self.OUTPUT)
if not fileName:
return {}

# search in context project's layers
if context.project():

for l in context.project().mapLayers().values():

# check the source
if l.source() != fileName:
continue

# reload provider's data
l.dataProvider().reloadData()
l.setCrs(l.dataProvider().crs())
l.triggerRepaint()

# search in context temporary layer store
for l in context.temporaryLayerStore().mapLayers().values():

# check the source
if l.source() != fileName:
continue

# reload provider's data
l.dataProvider().reloadData()
l.setCrs(l.dataProvider().crs())
context.temporaryLayerStore().addMapLayer(l)

return {}

0 comments on commit 6c44073

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