I am using Process Modeller to automate merging several vector layers and then creating a grid to cover the extent of the merged layer. There are functions which already exist which are not listed in the modeller such as :

Vector -> Research Tools -> Vector Grid

MMQGIS -> Create -> Create Grid Layer

The QGIS geoalgorithm Create grid in the modeller is not useful to me as I have to manually determine the position and set the CRS etc beforehand.

Is there any other plugin or function which allows me to accomplish this?

I am now trying to get the Processing plugin (formerly Sextante) to recognise the Vector Grid script. The file is named "doVectorGrid" which I renamed to simply "VectorGrid". I followed this advice: http://planet.qgis.org/planet/tag/sextante/ where it mentions at the bottom how to add your own modified algorithm.

I have added the new terms into the QGISAlgorithmProvider.py (the equilavent to FToolsAlgorithmProvider.py) but I get the following error: ImportError: cannot import name VectorGrid

I'm guessing I have to change the code of the Vector Grid script but I am new to Python. I have copied the ui_frmVectorGrid.py file into the same directory.

1 Answer 1


There's been somewhat of a development in QGIS since I asked this question back in 04/2014 so will post an answer to close off this question.

The following code does what I had wanted (practically similar to the "Hex grid from layer bounds" script but this wasn't available at the time):

##Create Grid=name
##cellsize=number 1000
##grid=output vector

input = processing.getObject(layer)

extent = input.extent()
xmin = input.extent().xMinimum() - cellsize / 2
xmax = input.extent().xMaximum() + cellsize / 2
ymin = input.extent().yMinimum() - cellsize / 2
ymax = input.extent().yMaximum() + cellsize / 2
crs = input.crs().authid()

processing.runalg('qgis:creategrid', 1, "%f, %f, %f, %f "% (xmin, xmax, ymin, ymax), cellsize, cellsize, crs, grid)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.