[GRASS-user] How to use the neighborhood modifier of grass:r.mapcalculator in PyQGIS

Hello,

I would like use r.mapcalculator in a PyQGIS processing script to change values from one raster in another accordingly. I don’t know how to call the variables row and col, which are now read as simple strings in the following code:

processing.runalg(‘grass:r.mapcalculator’,{“amap”: rlayer, “bmap”: emptylayer, “formula”: “amap[row,col]=bmap[(%i+row*%i),(%i+col*%i)]”% (offset,scale,offset,scale), “GRASS_REGION_PARAMETER”: “%f,%f,%f,%f”% (xmin, xmax, ymin, ymax), “outfile”: bdry_resamp})

Does anyone know the correct syntax to use this? It would be fine to do it manually calling the module from the processing toolbox in QGIS as well, but then I would have to specify the ‘formula’ as well.

Thanks,

Sophie