I need to identify public places within pedestrian areas in London, so I need to calculate the density of both pedestrian links and footways. I have classified my data according to the categorization method so I can see where there is the highest concentration in the map. However I would need to calculate the density.

I have a line shapefile and I could extract the nodes and then create a heat map. However I am afraid considering just the nodes would alter the dataset. Any suggestion?

  • Add evenly spaced nodes to the lines. That way the number of nodes one one line is comparable to the others. – csk May 9 '18 at 16:25
  • the tool for that is "densify by interval" – csk May 9 '18 at 18:02
  • Thank you. Another question: can you clip/intersect a lineshapefile according to a polygon shape? I want to cut streets where the ward ends so that they are not crossing two different wards and I can then perform the join attribute by location tool afterwards. This will allow me to calculate the density of street types within each ward in the field calculator. Does this method make sense? Thank you for your help! – Pinutz May 10 '18 at 9:21
  • Another method would be to convert the paths to polygons using a fixed-width buffer, then calculate the area of the buffers and use that as a ratio with the area of the ward. – csk May 10 '18 at 16:09
  • The tool for clipping a line layer by a polygon layer is called "Clip" and you can find it in the processing toolbox. – csk May 10 '18 at 16:14

Here my workaround:

1) Create an intersect of your lines layer (path/footways) and your polygon layer (grid or areas, e.g. neighborhoods) where you want to represent the density. Your polygons, areas, need a unique identifier (e.g. id). Make sure that the lines are the first object and, as you want to calculate distances, that both files are in the same projected coordinate system, with meters as a unit (e.g. in London UTM30N or EPSG:32630).

2) Open the attribute table of the intersect file. Open the field calculator and create a new field (e.g. road_length) of type real/decimal numbers. In the expression field type: $length. This will return the length of every segment in meters.

3) Run statistics by categories. Use the intersection layer as input, the field to calculate the statistics would be 'road_length', and the field with categories would be the unique identifier of your polygon file (id). As a result you get a table with the statistics of total road length for each of your ids or zones.

4) Join the attribute 'sum' to your polygon/grid layer using the unique id, and create a new attribute for road density (similar to step 2). This attribute is then: (sum_road_length/$area)

| improve this answer | |

This can be accomplished using the LecoS plugin, but you have to use QGIS V. 2.8 and it requires numpy, scipy and PIL (python imaging library) to be installed. Once you have the plugin running it has a vector overlay function. You create a buffer around the area where you want your spatial metrics and use the vector overlay function. It might require the batch process option, sometimes it is a little glitchy with the single querry - I just batch run and it works like a charm. There are multiple spatial metrics that this plugin offers - density is one of them.


| improve this answer | |

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.