Skip to content
Permalink
Browse files

[processing] set CRS for output grid (fix #12518)

  • Loading branch information
alexbruy committed Apr 10, 2015
1 parent 864443d commit 96d4003aa6a3edac79dd46e58e572400df6fbdc7
Showing with 4 additions and 6 deletions.
  1. +4 −6 python/plugins/processing/algs/qgis/Grid.py
@@ -34,18 +34,15 @@
from processing.core.parameters import ParameterExtent
from processing.core.parameters import ParameterNumber
from processing.core.parameters import ParameterSelection
from processing.core.parameters import ParameterCrs
from processing.core.outputs import OutputVector


class Grid(GeoAlgorithm):
TYPE = 'TYPE'
EXTENT = 'EXTENT'
WIDTH = 'WIDTH'
HEIGHT = 'HEIGHT'
HSPACING = 'HSPACING'
VSPACING = 'VSPACING'
CENTERX = 'CENTERX'
CENTERY = 'CENTERY'
CRS = 'CRS'
OUTPUT = 'OUTPUT'

@@ -67,14 +64,16 @@ def defineCharacteristics(self):
self.tr('Horizontal spacing'), default=10.0))
self.addParameter(ParameterNumber(self.VSPACING,
self.tr('Vertical spacing'), default=10.0))
self.addParameter(ParameterCrs(self.CRS, 'Grid CRS'))

self.addOutput(OutputVector(self.OUTPUT, self.tr('Output')))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Grid')))

def processAlgorithm(self, progress):
idx = self.getParameterValue(self.TYPE)
extent = self.getParameterValue(self.EXTENT).split(',')
hSpacing = self.getParameterValue(self.HSPACING)
vSpacing = self.getParameterValue(self.VSPACING)
crs = QgsCoordinateReferenceSystem(self.getParameterValue(self.CRS))

bbox = QgsRectangle(float(extent[0]), float(extent[2]),
float(extent[1]), float(extent[3]))
@@ -85,7 +84,6 @@ def processAlgorithm(self, progress):
centerY = bbox.center().y()
originX = centerX - width / 2.0
originY = centerY - height / 2.0
crs = QgsCoordinateReferenceSystem(self.getParameterValue(self.CRS))

if hSpacing <= 0 or vSpacing <= 0:
raise GeoAlgorithmExecutionException(

0 comments on commit 96d4003

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