3

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?

2

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")
0
processing.runAndLoad("qgis:heatmapkerneldensityestimation", {'INPUT':'[Path to input 
layer]','RADIUS':[value],'RADIUS_FIELD':None,'PIXEL_SIZE': 
[value],'WEIGHT_FIELD':None,'KERNEL':0,'DECAY':0,'OUTPUT_VALUE':0,'OUTPUT':'[path to 
 output].tiff'})

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 2
    Hey, welcome to GIS SE. Could you explain your answer? Answers are encouraged to have a small explanation instead of being one-liners. – Marcelo Villa Jul 18 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.