Skip to content
Permalink
Browse files

[processing] adopt algs to use new API call to retrieve GDAL driver

  • Loading branch information
alexbruy committed Aug 1, 2017
1 parent 0476d4e commit 14435907f60aefc46530bab8b5e8b07a5fcead45
@@ -30,11 +30,11 @@
from qgis.PyQt.QtGui import QIcon

from qgis.analysis import QgsAspectFilter
from qgis.core import (QgsProcessingParameterRasterLayer,
from qgis.core import (QgsRasterFileWriter,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import raster
from processing.tools.dataobjects import exportRasterLayer

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
@@ -75,7 +75,7 @@ def processAlgorithm(self, parameters, context, feedback):

outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)

outputFormat = raster.formatShortNameFromFileName(outputFile)
outputFormat = QgsRasterFileWriter.driverForExtension(os.path.splitext(outputFile)[1])

aspect = QgsAspectFilter(inputFile, outputFile, outputFormat)
aspect.setZFactor(zFactor)
@@ -25,6 +25,7 @@

__revision__ = '$Format:%H$'

import os
import math
import struct

@@ -36,7 +37,6 @@
QgsProcessingParameterCrs,
QgsProcessingParameterRasterDestination)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import raster


class CreateConstantRaster(QgisAlgorithm):
@@ -62,7 +62,7 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterNumber(self.PIXEL_SIZE,
self.tr('Pixel size'),
QgsProcessingParameterNumber.Double,
0.1, False, 0.001, 999))
0.1, False, 0.01, 999))
self.addParameter(QgsProcessingParameterNumber(self.NUMBER,
self.tr('Constant value'),
QgsProcessingParameterNumber.Double,
@@ -82,7 +82,7 @@ def processAlgorithm(self, parameters, context, feedback):
pixelSize = self.parameterAsDouble(parameters, self.PIXEL_SIZE, context)

outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
outputFormat = raster.formatShortNameFromFileName(outputFile)
outputFormat = QgsRasterFileWriter.driverForExtension(os.path.splitext(outputFile)[1])

rows = max([math.ceil(extent.height() / pixelSize) + 1, 1.0])
cols = max([math.ceil(extent.width() / pixelSize) + 1, 1.0])
@@ -31,6 +31,7 @@
from qgis.PyQt.QtGui import QIcon

from qgis.core import (QgsFeatureRequest,
QgsRasterFileWriter,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterFeatureSource,
@@ -43,7 +44,6 @@
from qgis.analysis import QgsKernelDensityEstimation

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import raster

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]

@@ -175,7 +175,7 @@ def processAlgorithm(self, parameters, context, feedback):
decay = self.parameterAsDouble(parameters, self.DECAY, context)
output_values = self.parameterAsEnum(parameters, self.OUTPUT_VALUE, context)
outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
output_format = raster.formatShortNameFromFileName(outputFile)
output_format = QgsRasterFileWriter.driverForExtension(os.path.splitext(outputFile)[1])
weight_field = self.parameterAsString(parameters, self.WEIGHT_FIELD, context)
radius_field = self.parameterAsString(parameters, self.RADIUS_FIELD, context)

@@ -30,11 +30,11 @@
from qgis.PyQt.QtGui import QIcon

from qgis.analysis import QgsHillshadeFilter
from qgis.core import (QgsProcessingParameterRasterLayer,
from qgis.core import (QgsRasterFileWriter,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import raster
from processing.tools.dataobjects import exportRasterLayer

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
@@ -84,8 +84,7 @@ def processAlgorithm(self, parameters, context, feedback):
vAngle = self.parameterAsDouble(parameters, self.V_ANGLE, context)

outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)

outputFormat = raster.formatShortNameFromFileName(outputFile)
outputFormat = QgsRasterFileWriter.driverForExtension(os.path.splitext(outputFile)[1])

hillshade = QgsHillshadeFilter(inputFile, outputFile, outputFormat, azimuth, vAngle)
hillshade.setZFactor(zFactor)
@@ -30,11 +30,11 @@
from qgis.PyQt.QtGui import QIcon

from qgis.analysis import QgsRuggednessFilter
from qgis.core import (QgsProcessingParameterRasterLayer,
from qgis.core import (QgsRasterFileWriter,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import raster
from processing.tools.dataobjects import exportRasterLayer

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
@@ -75,8 +75,7 @@ def processAlgorithm(self, parameters, context, feedback):
zFactor = self.parameterAsDouble(parameters, self.Z_FACTOR, context)

outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)

outputFormat = raster.formatShortNameFromFileName(outputFile)
outputFormat = QgsRasterFileWriter.driverForExtension(os.path.splitext(outputFile)[1])

ruggedness = QgsRuggednessFilter(inputFile, outputFile, outputFormat)
ruggedness.setZFactor(zFactor)
@@ -30,11 +30,11 @@
from qgis.PyQt.QtGui import QIcon

from qgis.analysis import QgsSlopeFilter
from qgis.core import (QgsProcessingParameterRasterLayer,
from qgis.core import (QgsRasterFileWriter,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import raster
from processing.tools.dataobjects import exportRasterLayer


@@ -75,8 +75,7 @@ def processAlgorithm(self, parameters, context, feedback):
zFactor = self.parameterAsDouble(parameters, self.Z_FACTOR, context)

outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)

outputFormat = raster.formatShortNameFromFileName(outputFile)
outputFormat = QgsRasterFileWriter.driverForExtension(os.path.splitext(outputFile)[1])

slope = QgsSlopeFilter(inputFile, outputFile, outputFormat)
slope.setZFactor(zFactor)

0 comments on commit 1443590

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