I'm using QGIS 2.18.16. I have a layer with 100k locations, each with several values in the attribute table (ex: mass, E impact, v, ...) for each point (imported via CSV file). I use a vector grid to count the number of spots for each square of 5m by 5m = ok so far. This gives me a heatmap of the number of hits.

I would like to add to each square an average of another value of each spot. (from csv file and in attribute table of hits layer) Ex: square A, has 250 hits(= individual values) those are already counted. But those hits in square A have each a different Energy impact. I would like to get the average E impact of these hits in each square for the same vector grid. This gives me different heatmap in the same vector grid. Not with the number of hits per 5x5m square but with the averag E impact.

The final goal is to generate a final layer by multiplying 2 or more values (number of hits, average E impact, presence of people, ...) for each same 5x5m square to obtain a final kind of heatmap that combines those factors for each 5x5m square.

Can this be done?

enter image description here

  • Thanks for the thorough explanation of the goal. I have been struggling with a similar challenge for a couple of hours now. I'm finding myself almost screaming "This shouldn't be so hard!" :-) – Brylie Christopher Oxley Jan 9 '20 at 15:14

I would suggest refFunctions plugin.

If your Telling layer is the grid, and Data layer is the points,

enter image description here

Open the attribute table of the Telling layer, and start Field calculator. Then create a new field with an expression intersecting_geom_sum( 'Data', 'E impact')/"hits".

(assuming "hits" is the field you have stored the number of hits).

enter image description here

Then Telling attribute table would be like below.

enter image description here

  • Hello. This works perfect! Is there a way that i can specify this for a specific square or a specific set of squares? This would save me a lot of time by not calculating squares that are not relevant. – stijn geldof Jan 28 '19 at 10:58
  • @stijngeldof It will be technically possible, by adding a condition such as IF or CASE WHEN functions. However it will increase the computation time, probably not what you want to. Sorry... – Kazuhito Jan 28 '19 at 11:33
  • Thank you Kazuhito, what would the correct expression be like then? with the IF or CASE WHEN functions. I would like to give it a try and compare both computation times. – stijn geldof Jan 28 '19 at 12:21
  • @stijngeldof Yes, if you have a field with a categorical value to specify such group; Let's say "group" field with 'A' and 'B'. Then CASE WHEN "group" = 'A' THEN intersecting_geom_sum('Data', 'E')/"hits" ELSE 0 .....(or something like that). – Kazuhito Jan 28 '19 at 12:55
  • I can't calculate it with this: when "id" = '710' then intersecting_geom_sum( 'WND0519_WT02_Ijsval finaal v2.12_Datareeks 1_990k', 'Overlijdenskans - Task 19')/"Numpoints" else ='0' – stijn geldof Jan 28 '19 at 15:17

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.