# Calculate number of people within 50 km of a point

I have two data sets:

I would like to calculate the number of people within for example 50 km from each point. What would be the best way of doing this in QGIS?

Best regards,

Magnus

-
I recommend reading about PostGIS (SQL) and R, might come handy if you need do more spatial analysis in future – simplexio Jan 28 '13 at 8:41
– Mapperz Jan 28 '13 at 14:52

Use Vector > Geoprocessing Tools > Buffer on your point shapefile to create a 50km radius circle around each point.

Use the Zonal Stats plugin (its a core plugin, but must be activated in Manage Plugins) to calculate the sum (among other stats) of the raster cells inside of each polygon of the resulting shapefile.

-
This only works provided no two points are closer than 50 km: when the buffers overlap, zonal stats will not be able to obtain the correct answer. Instead, compute a focal sum (with a 50 km radius circular neighborhood) and extract its values at each of the points in the shapefile. – whuber Jan 27 '13 at 23:40
Thank you for the answers. Two questions: - Since the data is in lat/long and I will use meters for the analysis, I will have to reproject the data to suitable coordinate system. Any suggestions on which one to use for a global data set? - The buffer zones will probably overlap. Can you tell me a bit more about how to compute a focal sum? Magnus – johnrobot Jan 28 '13 at 6:58
@whuber, I have never noticed problems using QGIS Zonal Stats plugin with overlaping polygons, but I know that it's a Problem in ArcGIS (9.3). I made a small test, using two polygons with the same shape\size, and overlap them. Using the QGIS plugin and the resulting count, sum and mean for each polygon was the expected. – Alexandre Neto Jan 28 '13 at 11:39
Very interesting! That's nice to know, and I am pleased to have been wrong about QGIS in this regard. Based on what you say, it sounds like the zonal stats solution should be preferred unless there are a very many points with very many overlaps, in which case the focal stats solution--with its much greater computational efficiency--may have some merit as an option. – whuber Jan 28 '13 at 17:14
Johnrobot, your query about a suitable global projection needs some careful thought. I would like to suggest you review similar questions on this site and then, if they do not indicate a solution, post that as a separate question. It looks like you could compute a variable distance buffer in a conformal projection, varying the radii with the scale. – whuber Jan 28 '13 at 17:21