I have 4k point shapefiles, from which I would like to generate heatmap TIFFs using the QGIS heatmap plugin (or a functional equivalent featuring triweigth, radius and cell size selection). Is there any way to batch / script / automate this? I.e. "add vector shapefile, run heatmap plugin with specific options, remove vector shapefile and raster heatmap, add next vector shapefile, repeat..."?
-
If you use the Processing Toolbox -> use rightclick on the function and select batch-processing :)– CurlewMar 11, 2014 at 10:34
-
Would do - if only the heatmap plugin would be part of the processing toolbox...– Raphael SusewindMar 11, 2014 at 14:11
-
A "Heatmap" is just a weighted kernel density estimation. Just look for instance at the Kernel Density Estimation tool from SAGA or one of the Grass functions– CurlewMar 11, 2014 at 14:43
-
Thats what I eventually did (see my answer below) - using grass, and conveniently shifting to the command line anyhow. Thanks for the hint though...– Raphael SusewindMar 11, 2014 at 15:04
1 Answer
For all I figured out, it is not possible to automate the heatmap - but GRASS has triweight KDE estimates, and CAN be scripted. Here is the general setup, to be put into a BASH file:
Heatmap generation from constituency.shp to constituency.tif would be like this (at the bottom of the BASH file):
v.in.ogr -e dsn=${GRASS_DBASE_EXAMPLE}/constituency.shp output=vector_layer ty$
g.mapset mapset=PERMANENT location=vector_location
g.region res=.0001
v.kernel --verbose -o input=vector_layer kernel=triweight output=raster_layer stddeviation=0.03
r.out.gdal input=raster_layer output=constituency.tif nodata=0