Sunday, 22 February 2015

grass - Can one batch-automate the creation of QGIS heatmaps?


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..."?



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:


http://geoinformatics.fsv.cvut.cz/gwiki/On_scripting_GRASS_GIS:_Building_location-independent_command_line_tools


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

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...