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 [...]
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
- Load in the two datasets. Wards and street center lines (zipped shapefiles). They are projected in EPSG:3435.
- 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. - 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.
- Add the “streets intersect wards” shapefile to the table of contents.
- 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?
- 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.
- 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”.
- Add the “streets intersect wards geom” shapefile to the table of contents.
- 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.
- 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.
ward | length (feet) | length (miles) | percentage of total |
|---|---|---|---|
| 1 | 345807.34 | 65.49 | 1.61% |
| 2 | 604081.37 | 114.41 | 2.81% |
| 3 | 471370.83 | 89.27 | 2.19% |
| 4 | 312105.07 | 59.11 | 1.45% |
| 5 | 376239.82 | 71.26 | 1.75% |
| 6 | 519319.58 | 98.36 | 2.41% |
| 7 | 397117.42 | 75.21 | 1.84% |
| 8 | 567918.60 | 107.56 | 2.64% |
| 9 | 569327.91 | 107.83 | 2.64% |
| 10 | 707862.60 | 134.06 | 3.29% |
| 11 | 515253.87 | 97.59 | 2.39% |
| 12 | 324479.13 | 61.45 | 1.51% |
| 13 | 547089.99 | 103.62 | 2.54% |
| 14 | 423481.79 | 80.20 | 1.97% |
| 15 | 344489.48 | 65.24 | 1.60% |
| 16 | 406311.44 | 76.95 | 1.89% |
| 17 | 424330.35 | 80.37 | 1.97% |
| 18 | 641569.81 | 121.51 | 2.98% |
| 19 | 735446.82 | 139.29 | 3.42% |
| 20 | 408400.76 | 77.35 | 1.90% |
| 21 | 589133.47 | 111.58 | 2.74% |
| 22 | 256745.36 | 48.63 | 1.19% |
| 23 | 641993.49 | 121.59 | 2.98% |
| 24 | 466948.11 | 88.44 | 2.17% |
| 25 | 361496.49 | 68.47 | 1.68% |
| 26 | 317806.79 | 60.19 | 1.48% |
| 27 | 547926.69 | 103.77 | 2.55% |
| 28 | 474052.26 | 89.78 | 2.20% |
| 29 | 363815.99 | 68.90 | 1.69% |
| 30 | 333088.81 | 63.09 | 1.55% |
| 31 | 347433.71 | 65.80 | 1.61% |
| 32 | 463078.13 | 87.70 | 2.15% |
| 33 | 265877.43 | 50.36 | 1.24% |
| 34 | 634497.64 | 120.17 | 2.95% |
| 35 | 306321.07 | 58.02 | 1.42% |
| 36 | 580915.90 | 110.02 | 2.70% |
| 37 | 350384.22 | 66.36 | 1.63% |
| 38 | 483220.50 | 91.52 | 2.24% |
| 39 | 430503.69 | 81.53 | 2.00% |
| 40 | 328572.83 | 62.23 | 1.53% |
| 41 | 812461.39 | 153.88 | 3.77% |
| 42 | 294048.02 | 55.69 | 1.37% |
| 43 | 233469.28 | 44.22 | 1.08% |
| 44 | 201064.67 | 38.08 | 0.93% |
| 45 | 598401.70 | 113.33 | 2.78% |
| 46 | 150713.42 | 28.54 | 0.70% |
| 47 | 372284.88 | 70.51 | 1.73% |
| 48 | 154459.21 | 29.25 | 0.72% |
| 49 | 179128.45 | 33.93 | 0.83% |
| 50 | 344845.36 | 65.31 | 1.60% |
| total | 21526692.94 | 4,077.03 | 100.00% |
Wards 19 (south side) and 41 (Norwood Park, including O’Hare airport) have the highest portion of street length in the city.
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
On February 5, 2013, I gave a very short presentation to the Chicago GIS Network Meetup group about alternatives to Google when it comes to mapping on the web. I created the presentation and outline a couple hours before giving it and came up with this slideshow with three frames.
Google Maps and its [...]
On February 5, 2013, I gave a very short presentation to the Chicago GIS Network Meetup group about alternatives to Google when it comes to mapping on the web. I created the presentation and outline a couple hours before giving it and came up with this slideshow with three frames.
Google Maps and its data is a one-way street (or many one-way streets). Google will take data but won’t give it back.
Google Maps has all of these features, but they’re easier to manipulate when you use an alternative. Alternatives like: MapBox, TileMill, OpenLayers, OpenStreetMap (made easy with JOSM), GeoCommons – I’m sure there are plenty more.
OpenStreetMap is the Wikipedia of online mapping and geographic data. Considering switching to OSM.
This interactive map was created for a Grid Chicago article to show the cities and Amtrak routes mentioned. Click and drag it around or hover your mouse on the red train station markers.
Want to create a map like that and publish it on your own website? It’s easy. I’ll show you [...]
This interactive map was created for a Grid Chicago article to show the cities and Amtrak routes mentioned. Click and drag it around or hover your mouse on the red train station markers.
Want to create a map like that and publish it on your own website? It’s easy. I’ll show you how to do it in less than 30 minutes. First, download the following files:
- TileMill application (for Mac, Windows, and Linux)
- Railroads in the United States (.zip) (which includes Amtrak routes in a separate shapefile) ~40MB
- Amtrak stations (.zip) (includes an Amtrak Cascades station in Vancouver, BC)
- State boundaries (.zip) ~40MB
- Illinois places (.zip) (these are municipalities)
All shapefiles are from the United States Department of Transportation, Bureau of Transportation Statistics’s National Transportation Atlas 2012 edition except for Illinois places, which comes from the Census Bureau’s TIGER project.
At the end of this tutorial, you’ll have a good introduction on how to find geographic data, build a map with TileMill, style the map, and publish it for the public. Your map will not look like mine as this tutorial doesn’t describe how to add labels or use the hover/info feature.
Tutorial to make Amtrak Illinois map
- Unzip the four ZIP files you downloaded and move their contents into a folder, like /Documents/GIS/Amtrak Illinois/shapefiles. This is your project folder.
- Install TileMill and open it.
- Set up a project. In the Projects pane, click “New Project”. In the filename field, title it “amtrak_illinois”. Ensure that the checkbox next to “Default data” is checked – this shows a world map and helps you get your bearings (but it’s not absolutely necessary).
- Get familiar with TileMill’s layout. Your new project will open with the map on the left side and your Carto style code on the right side. There are four buttons aligning the left edge of your map. From top to bottom they are: Templates, Font list, Carto guide, and Layers.
- Add a layer. We’re going to add the four shapefile layers you downloaded. Click the “Layers” button and then click “Add layer”. In the ID field, type in “amtrak_routes”. For Datasource, browse to your project folder and find “amtrak.shp” – this file has the Amtrak route lines. Then click “Done”. Click “Save & Style”.
- Style that layer. When you click “Save & Style” after adding a layer, your attention will be called to the Carto style code on the right side of TileMill. A section of code with the “amtrak_routes” #selector will have been inserted with some default colors and styles. If you know CSS, you will be familiar with how to change the Amtrak routes line styles. Change the “line-color” to “#000″. After “line-color”, add a new line and insert “line-opacity: 0.5;”. This will add some transparency to the line. Press the “Save” button above the code.
- Add remaining layers. Repeat Step 5 and add 3 more layers: “amtrk_sta.shp” (ID field: “amtrak_stations”), “state.shp” (ID field: “states”), and “tl_2012_17_place.shp” (ID field: “illinois_cities”).
- Hide bus stations. The Amtrak stations layer shows bus and ferry stations as part of Amtrak’s Thruway connections. You probably don’t want to show these. In your Carto style code, rename the #selector from “#amtrak_stations” to “#amtrak_stations[STNTYPE='RAIL']“. That makes the following style code only apply to stations with the “rail” type. Since there’s no style definition for things that aren’t of that type, they won’t appear.
Screenshot of my map.
Prepare your map for uploading
TileMill has many exporting options. You can save it as MBTiles and publish the map for free using MapBox (TileMill’s parent), or you can export it as image files (but it won’t be interactive), or you can display the map using the Leaflet JavaScript map library (which I use for the Chicago Bike Map app). This tutorial will explain how to export MBTiles and upload to MapBox, the server I’m using to display the map at the top of this page.
- Change project settings. To upload to MapBox, you’ll have to export your project as MBTiles, a proprietary format. Click the “Export” button above your Carto style code and click “MBTiles”. You’ll be asked to provide a name, description, attribution, and version. Input appropriate text for all but version.
- Adjust the zoom levels. Adjust the number of zoom levels you want (the more you have the longer it takes to export and upload your project, and you might exceed MapBox’s free 50 MB account limit). My map has zoom levels 8-11.
- Adjust the bounds. You’ll then want to draw your bounds: how much of the map’s geographic extents you want to export. Zoom to a level where you can see the entire state of Illinois in your map. Hold down the Shift key and drag a box around the state, plus a buffer (so viewers don’t fall of your map when they pan to the edges).
- Export your map. Click Export and watch the progress! On a four-year-old MacBook it took less than one minute to export the project.
- Bring the export to your project folder. When export finishes, click the “Save” button and browse to your project folder. Click the file browser’s save button.
- Upload to MapBox. Login to MapBox’s website and click “Upload Layer”. Browse to your project folder, select the .mbtiles folder, and click “Upload file”. Upon a successful upload, your map will display.
- Embed it in your website. Click the “Share” button in the upper left corner of your map and copy the embed code. Paste this into the HTML source code of a webpage (or in a WordPress post) and save that (I’m not going to provide instructions on how to do that).
Now you know how to find geographic data, build a custom map using the TileMill application, begin to understand how to style it, and embed your map for the public on a website or blog.
N.B. I was originally going to use QGIS to build a map and then publish a static image before I realized that TileMill + MapBox (the website) can build a map but publish an interactive feature instead of a static image. I’m happy I went that route. However, I did use QGIS to verify the data and even create a new shapefile of just a few of the key train stations on the Lincoln Service (the centerpiece of my Grid Chicago article).
While working on a private web application that I call Chicago Crash Browser, I added some code to show the share of pedestrian and pedalcyclist crashes. The site offers users (sorry I don’t have a web server that can make it public) a list of the “Top 10″ intersections in terms of bike crash frequency [...]
While working on a private web application that I call Chicago Crash Browser, I added some code to show the share of pedestrian and pedalcyclist crashes. The site offers users (sorry I don’t have a web server that can make it public) a list of the “Top 10″ intersections in terms of bike crash frequency (that’s bike+auto crash). You can click on the intersection and a list will populate showing all the pedestrian and pedalcyclist crashes there, sorted by date. At the bottom of the list is a simple sentence that tells what percentage pedestrian and pedalcyclists made up at that intersection.
I’m still developing ideas on how this information may be useful, and what it’s saying about the intersection or the people using it.
Let me tell you about a few:
Milwaukee Avenue and Ogden Avenue
I mentioned in my article Initial intersection crash analysis for Milwaukee Avenue that this intersection is the most bike crash-frequent.
23 crashes within 150 feet of the center, 2005-2010
82.61% bike crashes **
17.39% ped crashes.
Ashland Avenue and Division Street
28 crashes within 150 feet of the center, 2005-2010
46.43% bike crashes
53.57% ped crashes **
Milwaukee, North and Damen Avenues
46 crashes within 150 feet of the center, 2005-2010
39.13% bike crashes
60.87% ped crashes **
Halsted Street, Lincoln and Fullerton Avenues
38 crashes within 150 feet of the center, 2005-2010
42.11% bike crashes
57.89% ped crashes **
Montrose Avenue and Marine Drive (Lake Shore Drive ramps)
11 crashes within 150 feet of the center, 2005-2010
90.91% bike crashes **
9.09% ped crashes
Why do you think some intersections have more of one kind of crash than the other?
People walking at Milwaukee-North-Damen.
The Chicago Crash Browser can be made public if I have a host that offers the PostgreSQL database. Do you have one to offer?
About Steven Can Plan
I started this blog in 2007 as the writing assignment for an introductory urban planning class at UIC. It's about cities (mainly Chicago), GIS oftentimes, and transportation (mainly bicycling). Learn more about me, Steven Vance. I also write for Streetsblog Chicago.
Steven Can Plan is hosted on Dreamhost.
Chicago Bike Map App

The Chicago Bike Map app is a bike and street map stored entirely in your iOS device – no data connection required. The map is designed to look much like the City of Chicago's official printed and online bike map. The app works on iPhone, iPod touch, and iPad.
- Download from the iTunes Store
- Demo the app online
- On iOS, search for "chicago bike map" in the App Store app
Highly Recommended Bike Products

Planet Bike SuperFlash taillight
The best value taillight. It has three red LEDs that alternate and provide extreme brightness. I have two of these.

Brooks B67 leather sprung saddle
So far my longest trip was 40 miles on this saddle. It molds to your butt like Birkenstock sandals mold to your feet. The springs make the bike ride a little more comfortable and more fun (weird, because you bounce up and down on them). It also looks gorgeous. Comes in 3 colors - I got black.
Advertisement
Books

Joyride: Pedaling Toward A Healthier Planet by Mia Birk, With Joe (Metal Cowboy) Kurmaskie, Joe Kurmaskie, Jim Moore
I met Mia Birk in October 2011.

The Death and Life of Great American Cities (50th Anniversary Edition) (Modern Library) by Jane Jacobs

Traffic: Why We Drive the Way We Do (and What It Says About Us) by Tom Vanderbilt
As someone who doesn't like driving, but believes that cars can be efficient in moving groups of people and goods, this is my favorite book.

Sustainable Transportation Planning: Tools for Creating Vibrant, Healthy, and Resilient Communities (Wiley Series in Sustainable Design) by Jeffrey Tumlin
I was sent a review copy. I'm really excited to open it up and start reading because I've been disappointed with textbooks in the past that don't focus on bicycle and pedestrian planning.
Transit & Transportation











Are protected bike lanes going in the right places?
My contribution to a discussion on The Chainlink, Are protected bike lanes going in the right places?
Kelvin, Milwaukee/Ogden/Chicago is the intersection along Milwaukee Avenue with the highest number of bicycle crashes. I created this table and map to show them, using data from 2007-2009.
The blue rings on the [...]
My contribution to a discussion on The Chainlink, Are protected bike lanes going in the right places?
Kelvin, Milwaukee/Ogden/Chicago is the intersection along Milwaukee Avenue with the highest number of bicycle crashes. I created this table and map to show them, using data from 2007-2009.
The blue rings on the map are called, in GIS parlance, “buffers” and are circles used to select things (in this case, bike crashes) within a certain distance of the circle center. In this map I used 50 feet radius buffers (100 feet diameter). While this distance encompasses the intersection from center to all four curbs, it doesn’t encompass the crashes that happened just outside the buffer that were still most likely influenced by the intersection (like drivers’ turning movements).
I am working on a project with three friends to create a better map and “crash browser”. I mentioned it in the last story on Grid Chicago in this post. For this project, we are using 200 feet radius (400 feet diameter) buffers to ensure we encompass the entire intersection and the area in which it still has an effect. This also grabs the bike lane “pinch points”, places where a bike lane doesn’t start until 100-200 feet beyond the intersection.
I am also concerned with the strategy and approach CDOT is using to choose locations. It’s not transparent; at MBAC, CDOT said they were choosing locations “without controversy and that could be implemented quickly”.
Read more about Kinzie Street, Chicago’s first protected bike lane, and my other thoughts on protected bike lanes.