How many miles of roads are in your ward?

Flickr Tag Error: Call to display photo '8512612088' failed.

Error state follows:

  • stat: fail
  • code: 95
  • message: SSL is required

Screenshot 1: Showing how some streets are not being counted. There should be a yellow section of road between the two existing yellow road sections. 

A friend recently asked me how many blocks of road are in his ward. He wanted to know so that he could measure how many blocks of streets would have an older style of street lighting after X number of blocks receive the new style of street lighting. For this project, I used two datasets from Chicago’s open data portal: street center lines and wards. The output data is not very accurate as there may be some overlap and some uncounted street segments; this is likely due to a shortcoming in my process. I will show you how to find the number of blocks per ward using QGIS (download Quantum GIS, a free program for all OSes).

Here’s how I did it

  1. Load in the two datasets. Wards and street center lines (zipped shapefiles). They are projected in EPSG:3435.
  2. Exclude several road classifications in the street center lines by querying only for "CLASS" > '1' AND "CLASS" < '5'. The data dictionary for the road classifications is at the end. We don’t want the river, sidewalks, expressways, and any ramps to be included in the blocks per ward analysis.
  3. Intersect. In QGIS, select Vector>Geoprocessing Tools>Intersect. The input vector layer is “Transportation” (the name of the street center lines dataset) and the intersect layer is “Wards”. Save the resulting shapefile as “streets intersect wards”. Click OK. This will take a while.
  4. Add the “streets intersect wards” shapefile to the table of contents.
  5. You’ll notice some of the issues with the resulting shapefile: missing street segments (see screenshot 1). What should QGIS do if a street is a ward boundary?
  6. Obtain street length information, part 1. Remove all the columns in the “streets intersect wards” shapefile that have something to do with geometry. These are now outdated and will confuse you when you add a geometry column generated by QGIS.
  7. Obtain street length information, part 2. With the “streets intersect wards” shapefile selected in the table of contents, select Vector>Geometry Tools>Export/Add geometry columns. Select “streets intersect wards” shapefile as your input layer, leave CRS as “Layer CRS” and save as new shapefile “streets intersect wards geom”.
  8. Add the “streets intersect wards geom” shapefile to the table of contents.
  9. You will see a new column at the end of the attribute table called LENGTH. Since the data is projected in EPSG:3435 (Illinois StatePlane NAD83 East Feet), the unit is feet.
  10. Simply export “streets intersect wards geom” to a CSV file and open the CSV file in a spreadsheet application. From there you can group the data by Ward number and add the street lengths together. (I thought it would be faster to do this in a database so I imported it into a localhost MySQL database and ran a simple query, SELECT wardNum, sum(`chistreets_classes234`.`LENGTH`) as sum FROM chistreets_classes234 WHERE ward > 0 group by wardNum. I then exported this to a spreadsheet to convert feet to miles.)

Because of the errors described in step 5, you shouldn’t use this analysis for any application where accuracy is important. There are road lengths missing in the output dataset (table with street lengths summed by ward) and I cannot tell if the inaccuracy is equally distributed.

length (feet)
length (miles)
percentage of total

Wards 19 (south side) and 41 (Norwood Park, including O’Hare airport) have the highest portion of street length in the city.

Flickr Tag Error: Call to display photo '8511550077' failed.

Error state follows:

  • stat: fail
  • code: 95
  • message: SSL is required

Screenshot 2: Ward 41 is seen. 

Street data dictionary

Column is “CLASS”. The value is a string. This dataset lacks alleys. Adapted from the City’s data dictionary.

1. Expressway

2. Arterials (1 mile grid, no diagonals)

3. Collectors (includes diagonals)

4. Other streets (side streets, neighborhood streets)

5. Named alleys (mostly downtown, like Couch Place and Garland Place)

7. Tiered (lower level streets, including LaSalle, Michigan, Columbus, and Wacker)

9. Ramps (goes along with expressway)

E. Extent ( not sure how to describe these; includes riverwalk and lake walk segments, and Navy Pier, also includes some streets, like Mies van der Rohe Way)

RIV. River

S. Sidewalk

99. Unclassified

flattr this!

About Steven Vance

Enthusiast for urbanism, bicycling as transportation, and open data. Building a bicycle culture in Chicago.
  • Jennifer

    How many roads must a man remove from a shapefile before he can count them in your ward?

    The answer, my friend, is blowing in the wind, the answer is blowing in the wind…

  • Daniel Howard

    I had to look at the screenshot to figure out that the software we are using in this tutorial is called “Quantum GIS”

    … which I am installing, at present :)

    • Steven Vance

      Did I not say QGIS in the article? I use QGIS exclusively. ArcGIS and ESRI can suck it.

      • Daniel Howard

        Step 3 makes a mention of QGIS. I figured out the software package by looking at the screenshot. I made it as far as Step 3, realized I was way too newb for this, then spent the next several hours playing with a map of the national railroad network, Amtrak, and transit stations. So, you’ll get no gripes from me! (Thank you for this first hit of smack!)

        Suggestions, though:

        1) Mention “Quantum GIS” in the first paragraph or so.

        2) Wrap your Query syntax (step 2) in CODE markup, I think that will dissuade WordPress from molesting your glyphs. :)

        Oh and one last random-ass question: are tech-savvy urban planning nerds going to lose some productivity after SimCity 5 is released March 5 or is that stuff too childish for you folks? :>


        • Steven Vance

          Suggestions accepted.

          I haven’t played SimCity since 3000, which I didn’t like as much as SimCity 2000. I’ve read that SimCity 5 still has a huge focus on car transportation and that you can’t built a streetcar unless it’s in the middle of a street.

          Once you learn how to edit data, you should publish them on MapBox. I made an Amtrak map. Here’s how I did it.