3

I'm trying to produce a raster layer. The aim is to show the summed heat consumption of every cell (100*100m).

I created an point layer with all buildings and an attribute with their heat consumption. Using the Rasterize (Polygon to Raster) funtion I can choose the attribute field heat consumption, but the output doesn't show the sum of the attribute heat consumption in every cell. The value of every cell is a random value of one building inside and not the sum of all buildings inside.The problem is I need the sum of every building inside the cell. I tested a lot of different ways to find a solution, since I'm still on beginner level, it's hard for me to find out a way to calculate this.

4

There's probably a simpler way but I would do the following:

  1. Create a 100x100m vector grid around your points layer (to match the cellsize of your raster):

    Vector > Research Tools > Vector Grid
    
  2. The grid should have an id field containing unique values. Join the grid to your point layer so that your points layer also contains the id field:

    Vector > Data Management Tools > Join attributes by location
    
  3. 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")
    
  4. Each point with a certain id should now contain the sum of the heat consumption. Use this new field for your rasterisation.

1

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.

GDAL rasterize in QGIS

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.