Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a vector file containing points with an attributed value (no. of employes at that location). I need to create a hectare raster with the sum of employes for each grid cell. I'm using QGIS and have so far played around with gdal_rasterize gdal_grid but with no success. I'm not even sure if I'm looking at the right tool. Can anyone give me a hint?

share|improve this question

Assuming you know how to create the hectare sized grid (using the Vector->Research tools->Vector grid) then you can import both the point shapefile and the grid polygons into SpatiaLite and with an aggregate query get the totals as an attribute column in each grid sqare. For example if you have an id column in the grid polygon layer, and a num_employees column in the points layer, then:

Using spatialite, import the two shapefiles:

.loadshp employee_points points utf-8 4326
.loadshp grid grid utf-8 4326

Add new columns in the grid layer for the totals. You can also get averages, etc while you're at it...


Now do the UPDATE to populate those columns with a SELECT query that uses the SQL aggregate "SUM" and the ST_Contains() function. The second part of the WHERE clause matches each select to the correct row in the outer UPDATE statement:

UPDATE grid SET ttl_employees=(
SELECT SUM(p.num_employees) 
FROM points AS p, grid AS g
WHERE ST_Contains(g.Geometry, p.Geometry) AND =
UPDATE grid SET avg_employees=(
SELECT AVG(p.num_employees) 
FROM points AS p, grid AS g
WHERE ST_Contains(g.Geometry, p.Geometry) AND =
UPDATE grid SET cnt_pts=(
FROM points AS p, grid AS g
WHERE ST_Contains(g.Geometry, p.Geometry) AND =
share|improve this answer
I got the data from the provider in a hectar raster. Therefor I haven't tried your solution yet. But as it's a quite common problem, I will surely get to it in another project soon. Thanks anyway! – Pascal Mages Jun 10 '13 at 10:26

It depends on your initial projection, but lets assume its distance units are meters.

  • You create a vector grid with QGIS using the standard vector tools or mmqgis. 1ha equals 10,000 m², therefore you need to specify your grid size (ratio) according to that.
  • After you have created the grid, just conduct a spatial join which sums up the number of employees per vector grid cell.
  • Then use the gdal_rasterize command to rasterize your vector grid
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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