QGIS - point to raster - Summing attributes as value of raster
There's probably a simpler way but I would do the following:
Create a 100x100m vector grid around your points layer (to match the cellsize of your raster):
Vector > Research Tools > Vector Grid
The grid should have an
id
field containing unique values. Join the grid to your point layer so that your points layer also contains theid
field:Vector > Data Management Tools > Join attributes by location
Each point should lie inside a grid cell and contain its ID. Now use the Field Calculator for your point layer to create a new field to calculate the sum of the heat consumption for each grid cell using the following expression:
sum( "heat_consumption_field", group_by:="id")
Each point with a certain id should now contain the sum of the heat consumption. Use this new field for your rasterisation.
I have the same issue and find the proposed solution to be very tedious and inefficient for large data. If you know how to work with R it is quite easy. here is a minimal reproducuble example:
library(raster)
# create Vector layer
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
plot(meuse)
# create a baseraster for rasterization
baseraster<-raster(ext=extent(meuse),
resolution=c(100,100),
crs=CRS(proj4string(meuse)))
# rasterize zinc measurements in meuse river, using observation averages
meuse_rasterized<-rasterize(meuse,baseraster,field="zinc",fun=mean)
plot(meuse_rasterized)
Another and programmatically much more efficient alternative is to use GDAL which can be used from CLI, with Python or with wrapper functions from the gdal utils
package in R. The GDAL function is called gdal_rasterize
and you will have to use the -add
parameter in order to sum up the count of points per gridcell.
It seems to me that you can also do this from Inside QGIS if you go to the -> toolbox and search for "rasterize". you should see the GDAL rasterize function where you can set all parameters. Note that you will have to use the "Advanced parameters" and put the -add
in the Additional creation parameters
.