I am using QGIS 2.18.13.
I have a few shapefiles. From inside QGIS, using python's processing.runalg function and supplying "grass7:v.to.rast.attribute", I converted those to raster files which have value of 1 everywhere shapes were present and "no data" (255) beyond them.
Those rasters share the same spatial location and I would like to "add them" so if in the same location there are 3 values 1 in final raster there will be value 3. So, I will be happy to have nodata converted to 0s for that purpose.
I tried following things where I didn't get results, I found some limitations or I got no results at all.
Raster -> raster calculator - I don't have any control over resolution. It was produced uncompressed tiff (400MB! from my 10000x10000 raster), 32 bit precision and nodata values changed to -3.40282e+38. Where it was nodata before I get nodata so, resulting raster is some kind of intersection rather than sum.
Toolbox -> GRASS GIS 7 -> Raster -> r.null. I get this error: "The following layers were not correctly generated. NullRaster"
toolbox -> GRASS GIS 7 -> Raster -> r.mapcalc. I don't know how to write an expression. I always get either parse error or:
r.mapcalc expression="abc = 1" --overwrite r was unexpected at this time.
there are usually 4 lines in the log like this:
ERROR: Sorry is not a valid option
toolbox -> SAGA -> Raster calculus -> Raster calculator - that one seems not to throw errors, however, I am not sure how to handle NaN's?
I would like to add this to python script so I can automate the process if my base datasets change.