Monday 18 March 2019

python - QGIS using the heatmapplugin from the console


I have to make a lot of heatmaps from csv's. Therefore I'm making a python script to run in the console.


So far I can load csv's and save them as shapefiles. To get to the heatmapplugin I'm using the following code:


rasterMenu = qgis.utils.iface.rasterMenu()
for rasterMenuItem in rasterMenu.actions():
if 'Heatmap' in rasterMenuItem.text():
heatmapMenu = rasterMenuItem

for heatmapMenuItem in heatmapMenu.menu().actions():
print heatmapMenuItem

if 'Heatmap' in heatmapMenuItem.text():
heatmapMenuItem.trigger()

Now I'm stuck. Does somebody know how to select the heatmap menu and enter the correct variables from the console?



Answer



I finally figured it out!


Instead of the heatmapplugin I used the kernel density estimation algorithm:


import processing
processing.runandload("saga:kerneldensityestimation", "path/to/shapefile.shp", "name of the colums with weigths", radius, 0, 0, None, celsize, "path/to/raster.tif")

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