I have a shapefile with 52K points of road accidents, between 2007 and 2012.

Each accident has a severity index. I want show clusters of 5 accidents (at least), for each year, that have a severity index equal or above 20, and that are in a 100 meters radius of the same road.

I tried already create buffers of 100 meters and intersect the buffers, but I was unable.

I'm working on QGIS 2.0.1.

Can you help me?


First of all, you're dealing with @52k points so whenever you're running an analysis with this amount of data, chances are QGIS looks frozen but more often than not it is still processing (can check this with Task Manager and CPU usage).

To start, we need to filter out all the unnecessary points we don't want so I suggest making and using a duplicate layer and saving that as another shapefile. Load your Attribute Table and select the Advanced Filter (Expression):

Attribute table

Use this expression and apply:

 "VL_GRAVIDA" >= 20

Select ALL of the points shown and then select Show All Features. Invert the selection and delete the fields. This massively reduces your data to less than 3k points making further analysis to be conducted much quicker. Make sure to save the edits.

Do your Buffer analysis of 100m and run the Intersection tool with your roads layer. We will use this newly intersected layer.

Now, download and install the Group Stats plugin via Plugins > Manage and Install Plugins.... We will use this to count how many polygons lie on the same road using the "COD_VIA" field (thank you for pointing this out!). Click/drag the "COD_VIA" field from the Fields list into the Rows and Values boxes as shown in the image below. Go down the Fields list to find various functions, repeat for count in the Values box and click Calculate:

You now have the total number of polygons which lie on the same road. Sort by the second column and go down the list until you reach the first field with a count of 5. Select this field, go down the list, hold left_shift and select the last field. Go to Data > Copy selected to clipboard (saving it as a .csv file does not save the count values).

Group Stats

Open up a spreadsheet program and paste the values. You can rename the second column if you wish although it's not necesssary (I simply renamed it to COUNT). Save this as a .csv file:


Drag the .csv file into QGIS, we will be joining this with the intersected layer. Open the Layer Properties > Joins > match the fields:


Now your attributes for the intersected layer contains the number of counts for each road. Open the Attribute Table and sort by the newly added column at the end, we will now delete all fields with NULL counts:

Delete NULLS from Attribute Table

Save the edits. You now have a layer of fields with a Severity Index >= 20 and atleast 5 polygons on the same road. Repeat the method with the Group Stats plugin for having 5 fields in each year.

So now you have a layer filtered out with your requirements:

  • Severity Index >= 20
  • 100 metres within the nearest road
  • Atleast 5 accidents per road
  • Data for each year from 2007 to 2012

And you can play with the Styles to make it more visually appealing. I added a style that shows the radius of 100m around the central point and used the OpenLayers plugin as the background:


Just an added note in terms of visualising points data, I like to personally use Heatmaps (Interpolation > Heatmaps) and play around with the colours to get some nice results:


  • Hi @Joseph. I have a roads shapefile, but my goal is only show a buffer where are 5 or more accidentes, that belongs to the same road (attribute COD_VIA) and that have a severity index (VL_GRAVIDA) >= 20, like a cluster. Can you help me with that? – Luís Ramos Oct 23 '14 at 17:21
  • Any ideas, people? – Luís Ramos Oct 25 '14 at 15:42
  • Sorry @Joseph, it's really nice and it's helpful, but is not what I need. In my last comment I didn't explain everything like I did in the first one. I need the buffer only on section of the road (100 meters radius) where are >= 5 accidents, by year, where there sum of the VL_GRAVIDA it's >= 20. Thanks for your support, LR – Luís Ramos Oct 28 '14 at 15:37
  • No problem buddy, hope you get the results you're looking for! – Joseph Oct 28 '14 at 15:43

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.