vendredi 27 février 2015

Why processing.runalg("gdalogr:rasterize"....) is not creating out files when running in the QGIS 2.6.0 console?


I want to the QGIS python scripting functions to turn to rasterize a point vector using many different dimensions.


Right now my code looks like this:



import processing

RasterPixelSize = (10.0,20.0,30.0,40.0,50.0,60.0,70.0,80.0,90.0,100.0)

for rps in RasterPixelSize:
processing.runalg("gdalogr:rasterize","/home/cparr/Documents/Inuvik /West_Hourglass/spiral.shp","DEPTHCM_AL",None,0,[rps],[rps],0,"/home/cparr/Documents/Inuvik/SpiralToRaster/test.tif")

print "Done"


And in the console I get this message:



execfile(u'/home/cparr/Documents/Inuvik/QgisScripts/rasterize.py'.encode('UTF-8'))
Error: Wrong parameter value: [10.0]
Error: Wrong parameter value: [20.0]
Error: Wrong parameter value: [30.0]
Error: Wrong parameter value: [40.0]
Error: Wrong parameter value: [50.0]
Error: Wrong parameter value: [60.0]
Error: Wrong parameter value: [70.0]
Error: Wrong parameter value: [80.0]
Error: Wrong parameter value: [90.0]
Error: Wrong parameter value: [100.0]
Done


The help for rasterize shows:



processing.alghelp("gdalogr:rasterize")
ALGORITHM: Rasterize (vector to raster)
INPUT <parameters>
FIELD <parameters from INPUT>
WRITEOVER <parameters>
DIMENSIONS <parameters>
WIDTH <parameters>
HEIGHT <parameters>
RTYPE <parameters>
OUTPUT <OutputRaster>


DIMENSIONS(Set output raster size (ignored if above option is checked))
0 - Output size in pixels
1 - Output resolution in map units per pixel
RTYPE(Raster type)
0 - Byte
1 - Int16
2 - UInt16
3 - UInt32
4 - Int32
5 - Float32
6 - Float64
7 - CInt16
8 - CInt32
9 - CFloat32
10 - CFloat64


And I believe my parameters are correct. Does anyone have experience scripting the QGIS processing tools from the python console? Or is there a better approach?


Thank you!



  • Charlie





Aucun commentaire:

Enregistrer un commentaire