Calculating Street Intersection Density (QGIS3)

Street intersection density is a useful measure of network connectivity. One can extract and aggregate street intersections over a regular grid to calculate the density. This analysis is commonly used in transportation design as well as urban planning to determine walkability of neighborhoods. With the availability of global street network dataset from OpenStreetMap and QGIS, we can easily calculate and visualize intersection density for any region of the world.

Overview of the task

In this tutorial, we will take OpenStreetMap road network data and calculate the street intersection density for the city of Chennai in India.

Other skills you will learn

  • How to download OpenStreetMap data as shapefiles and clip it to your area of interest.

  • How to create grids in QGIS.

Get the data

We will use the data from opencities to get the city boundary for Chennai and, then the road network data from OpenStreetMap Data Extracts for India.

Download the City Boundary

  1. Visit the opencity website, then search for “Chennai wards map”.

../../_images/data11.png
  1. Click on the first link and download the data in KML format. A layer Chennai-wards-2011.kml will be downloaded.

../../_images/data2.png

Download the Road Network

  1. Visit the OpenStreetMap Data Extracts download server by GEOFABRIK. For this tutorial, we need the data for the city of Chennai in India. Click Asia.

../../_images/data3.png
  1. Now in sub-regions, select India.

../../_images/data4.png
  1. The india-latest-free.shp.zip is the file we are looking for click it to download, this data can be downloaded in other formats also as per requirement.

../../_images/data5.png
  1. This is a large download containing an extract of data for the entire country. Unzip the india-latest-free.shp.zip. You will get many shapefile layers.

../../_images/data6.png

Clip the Road Network to the City Boundary

  1. We will now clip the country-level roads layer to our area of interest. Open QGIS, and drag and drop the Chennai-wards-2011.kml.

../../_images/data7.png
  1. Instead of opening a large layer in QGIS, we can directly read it from the disk and clip it. Open the Processing Toolbox and locate the Vector overlay ‣ Clip algorithm. Double-click to open it.

../../_images/data8.png
  1. In the Input layer select the and click on Browse for Layer…

../../_images/data9.png
  1. Navigate to the directory where you downloaded the OpenStreetMap data and select gis_osm_roads_free_1.shp. In the Overlay layer choose New Wards from Oct 2011. Then click in Clipped and select Save to File…, browse to a folder where you want to save the results, enter the name as chennai_roads.gpkg, and click Run.

../../_images/data10.png
  1. Once the processing finishes, a new layer chennai_roads will be loaded in the canvas.

../../_images/data111.png

For convenience, you may directly download a copy of the clipped dataset from the link below:

Data source: [OPENCITIES] [GEOFABRIK]

Procedure

  1. Now both layers used for the calculation will be available, if you have downloaded the data, then locate the Chennai-Wards-2011.kml and chennai_roads.gpkg in Browser, then drag and drop them on the canvas.

../../_images/image1.png
  1. The first task is to extract the road intersections. This can be done using the built-in Line intersections tool. Let’s test this on a small subset first to see if the results are satisfactory. Select the roads layer, and use the Select features by Area tool to draw a rectangle and select a few roads.

../../_images/image2.png
  1. Open the Processing Toolbox and locate the Vector overlay ‣ Line intersections algorithm. Double-click to open it.

../../_images/image3.png
  1. Select chennai_roads as both Input layer and Intersect layer. Make sure to check the Selected features only. Click Run.

../../_images/image4.png
  1. A new layer Intersections will be added. You will notice that while most intersection points are correct, there are some false positives. This is because the algorithm considers intersections of each line segment as a valid intersection. But for our analysis, we need to extract only the intersections when 2 or more streets intersect.

../../_images/image5.png
  1. Remove the Intersections layer and click Deselect features from all layers button to remove the selection. We will now merge all adjacent road segments, so the segments between intersections are merged into a single feature. Open the Processing Toolbox and locate the Vector geometry ‣ Dissolve algorithm. Double-click to open it.

../../_images/image6.png
  1. Select chennai_roads as the Input layer. Enter the Dissolved output layer name as roads_dissolved.gpkg. Click Run.

../../_images/image7.png
  1. The resulting layer roads_dissolved has all the road segments merged into a single feature.

../../_images/image8.png
  1. Next, open the Processing Toolbox and locate Vector geometry ‣ Multipart to single parts algorithm. Double-click to open it. Select roads_dissolved layer as the Input layer. Enter roads_singleparts.gpkg as the Single parts output. Click Run.

../../_images/image9.png
  1. The resulting layer roads_singleparts will have all adjacent segments merged, remove the roads_dissolved and chennai_roads layers. Now, open the Processing Toolbox and locate the Vector overlay ‣ Line intersections algorithm. Double-click to launch it.

../../_images/image10.png
  1. Select roads_singleparts as both the Input layer and the Intersect layer. Name the Intersections output layer as roads_line_intersections.gpkg. Click Run.

../../_images/image11.png

Note

This is a computationally intensive operation and may take a long time depending on your computer processing capacity.

  1. The resulting layer roads_line_intersections now has all intersections correctly identified. But it is still not perfect. Use the Select features by Area tool and select any intersection. You will see that at each intersection there are few duplicate points from adjacent segments. If we use this layer for further analysis, it will result in an inflated number of intersections. Let’s remove duplicates, open the Processing Toolbox and locate the Vector general ‣ Delete duplicate geometries algorithm. Select roads_line_intersections as the Input layer and enter road_intersections.gpkg as the Cleaned output layer. Click Run.

../../_images/image12.png
  1. The new road_intersections layer has the correct number of road intersections extracted from the source layer. Right-click the old road_line_intersections layer and select Remove layer to remove it.

../../_images/image13.png
  1. We will now compute the density of points by overlaying a regular grid and counting points in each grid polygon. We must reproject the data to a projected CRS so we can use linear units of measurements. We can use an appropriate CRS based on the UTM zone where the city is located. You can see UTM Grid Zones of the World map to locate the UTM zone for your city. Chennai falls in the UTM Zone 44N. Open the Processing Toolbox and locate the Vector general ‣ Reproject algorithm. Double click to open it.

../../_images/image14.png
  1. Select road_intersections as the Input layer. Search by clicking the globe icon next to Target CRS and select EPSG:32664 - WGS 84 / UTM zone 44N. This is a CRS based on the WGS84 datum for the UTM Zone 44N. Enter the Reprojected output layer as road_intersections_reprojected.gpkg. Click Run.

../../_images/image15.png
  1. Once the processing finishes and the road_intersections_reprojected layer is added, right-click and select Layer CRS ‣ Set Project CRS from Layer. And remove the road_intersections layer.

../../_images/image16.png
  1. Now we can create the grid. Open the Processing Toolbox and locate the Vector creation ‣ Create grid algorithm. Double click to open.

../../_images/image17.png
  1. Select Grid type as Rectangle (Polygon). Click the ... button in Grid extent and select Calculate from Layer ‣ road_intersections_reprojected.

../../_images/image18.png
  1. Select the Project CRS as the Grid CRS. We want to create a grid of 1km x 1km, so set both Horizontal spacing and Vertical spacing as 1000 meters. Save the Grid output layer as grid.gpkg. Click Run.

../../_images/image19.png
  1. The grid layer containing rectangular grid polygons will be created. We can now count the number of points in each polygon, but since our layers are large, this process can take a long time. One way to speed up spatial operations is to use a Spatial Index. Open the Processing Toolbox and locate the Vector general ‣ Create spatial index algorithm. Double click to open it.

../../_images/image20.png
  1. Select grid layer and click Run, now the layer will have a spatial index which can boost the performance of computation with this layer.

../../_images/image21.png
  1. Open the Processing Toolbox and locate the Vector analysis ‣ Count points in polygon algorithm.

../../_images/image22.png
  1. Select grid as the Polygon layer and road_intersections_reprojected as the Points layer. Save the Count output layer as grid_count.gpkg. Click Run.

../../_images/image23.png
  1. The resulting layer grid_count will have an attribute NUMPOINTS which contains the number of intersection points within each grid. There are many grids with 0 points. It will help our analysis and visualization to remove grid polygons that contain no intersections. Open the Processing Toolbox and locate the Vector selection ‣ Extract by attribute algorithm.

../../_images/image24.png
  1. Select grid_count as the Input layer, then select NUMPOINTS in Selection attribute, > in Operator and enter 0 as the Value. Save the Extracted (attribute) output layer as grid_counts_chennai.gpkg. Click Run.

../../_images/image25.png
  1. The resulting layer grid_counts_chennai will have grid polygons over the Chennai city and contains the number of road intersections as an attribute for each polygon. Remove all layers except grid_counts_chennai.

../../_images/image26.png
  1. Let’s clean up the attribute table of our data layer. The preferred method to make any changes to the attribute table is to use a processing algorithm called Refactor Fields, open the Processing Toolbox and locate the Vector table ‣ Refactor Fields algorithm. Double-click to open it. Click on any row in the Field Mapping section to select it. You can hold the Shift key to select multiple rows, select all fields except fid and NUMPOINTS. Click the Delete selected fields button.

../../_images/image27.png
  1. Rename the NUMPOINTS field as intersection_density and save the layer as road_intersection_density.gpkg, click Run.

../../_images/image28.png
  1. Let’s style this layer to view the density of each grid, select the road_intersection_density layer and click Open the Layer Styling Panel. Select Graduated renderer, and in Values select Intersection Density, a Color ramp of your choice, set the classes to 7 and click Classify.

../../_images/image29.png
  1. In the values enter 0-50, 50-100, 100-150 and so on up to 300 - 350. You have now created a map showing intersection density across the city.

../../_images/image30.png
comments powered by Disqus