Currently viewing the tag: "QGIS"

Array

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.

ward
length (feet)
length (miles)
percentage of total
1345807.3465.491.61%
2604081.37114.412.81%
3471370.8389.272.19%
4312105.0759.111.45%
5376239.8271.261.75%
6519319.5898.362.41%
7397117.4275.211.84%
8567918.60107.562.64%
9569327.91107.832.64%
10707862.60134.063.29%
11515253.8797.592.39%
12324479.1361.451.51%
13547089.99103.622.54%
14423481.7980.201.97%
15344489.4865.241.60%
16406311.4476.951.89%
17424330.3580.371.97%
18641569.81121.512.98%
19735446.82139.293.42%
20408400.7677.351.90%
21589133.47111.582.74%
22256745.3648.631.19%
23641993.49121.592.98%
24466948.1188.442.17%
25361496.4968.471.68%
26317806.7960.191.48%
27547926.69103.772.55%
28474052.2689.782.20%
29363815.9968.901.69%
30333088.8163.091.55%
31347433.7165.801.61%
32463078.1387.702.15%
33265877.4350.361.24%
34634497.64120.172.95%
35306321.0758.021.42%
36580915.90110.022.70%
37350384.2266.361.63%
38483220.5091.522.24%
39430503.6981.532.00%
40328572.8362.231.53%
41812461.39153.883.77%
42294048.0255.691.37%
43233469.2844.221.08%
44201064.6738.080.93%
45598401.70113.332.78%
46150713.4228.540.70%
47372284.8870.511.73%
48154459.2129.250.72%
49179128.4533.930.83%
50344845.3665.311.60%
total21526692.944,077.03100.00%

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

Array

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

Tagged with:
 

Array

A screenshot of the splash image seen on users with iPad retina displays in landscape mode. 

To make the Chicago Offline Bike Map, I need bikeways data. I got this from the City of Chicago’s data portal, in GIS shapefile format. It has a good attribute table listing the name of the street the bikeway is on and the bikeway’s class (see below). After several bike lanes had been installed, I asked the City’s data portal operators for an updated shapefile. I got it a month later and found that it wasn’t up-to-date. I probably could have received a shapefile with the current bikeway installations marked, but I didn’t have time to wait: every day delayed was one more day I couldn’t promote my app; I make 70 cents per sale.

Since the bikeway lines were already there, I could simply reclassify the sections that had been changed to an upgraded form of bikeway (for example, Wabash Avenue went from a door zone-style bike lane to a buffered bike lane in 2011). I tried to do this but ran into trouble when the line segment was longer than the bikeway segment that needed to be reclassified (for example, Elston Avenue has varying classifications from Milwaukee Avenue to North Avenue that didn’t match the line segments for that street). I had to divide the bikeway into shorter segments and reclassify them individually.

Enter the Split Features tool. QGIS is short on documentation and I had trouble using this feature. I eventually found the trick after a search that took more time than I expected. Here’s how to cut a line:

  1. Select the line using one of the selection tools. I prefer the default one, Select Features, where you have to click on the feature one-by-one. (It’s not required that you select the line, but doing so will ensure you only cut the selected line. If you don’t select the line, you can cut many lines in one go.)
  2. Toggle editing on the layer that contains the line you want to cut.
  3. Click Edit>Split Features to activate that tool, or find its icon in one the toolbars (which may or may not be shown).
  4. Click once near where you want to split the line.
  5. Move the cursor across the line you want to split, in the desired split location.
  6. When the red line indicating your split is where you desire, press the right-click mouse button.

Your line segment has now been split. A new entry has been added to the attribute table. There are now two entries with duplicate attributes representing that together make up the original line segment, before you split it.

Array

This screenshot shows a red line across a road. The red line indicates where the road will be split. Press the right-click mouse button to tell QGIS to “split now”.

Array

After splitting, open the attribute table to see that you now have two features with identical attributes. 

Copying features in QGIS

A second issue I had when creating new bikeways data was when a bikeway didn’t exist and I couldn’t reclassify it. This was the case on Franklin Boulevard: no bikeway had ever been installed there. I solved this problem by copying the relevant street segments from the Transportation (roads) shapefile and pasted them into the bikeways shapefile. New entries were created in the attribute table but with blank attributes. It was simple to fill in the street name, class, and extents.

Chicago bikeways GIS description

Bikeway classes (TYPE in the dataset) in the City of Chicago data portal are:

  1. Existing bike lane
  2. Existing marked shared lane
  3. Proposed on-street bikeway
  4. Recommended bike route
  5. Existing trail
  6. Proposed off-street trail
  7. Access path (to existing trail)
  8. Existing cycle track (also known as protected bike lane)
  9. Existing buffered bike lane

It remains to be seen if the City will identify the “enhanced marked shared lane” on Wells Street between Wacker Drive and Van Buren street differently than “existing marked shared lane” in the data.

Tagged with:
 

List of the most crash-prone intersections on Milwaukee Avenue in Chicago. Using data from 2007-2009, when reported to the Chicago Police Department. Dooring data not included on the bike crash map. I used QGIS to draw a 50-feet buffer around the point where the intersection center lines meet.

Intersecting street (class 4*) Bike crashes
Chicago Avenue (see Ogden below) 12 (17)
California Avenue 9
Halsted Street & Grand Avenue 7
Damen Avenue & North Avenue 6
Western Avenue 6
Ogden Avenue (see Chicago above) 5 (17)
Ashland Avenue 5
Diversey Avenue 5
Fullerton Avenue 5
Elston Avenue 5
Augusta Boulevard (not class 4) 5

Combine the six-way (with center triangle) intersection of Ogden, Milwaukee, Chicago, and you see 17 crashes. Add the 6 just outside the 50-feet buffer and you get 23 crashes. Compare this to the six-way (without center triangle) at Halsted, Milwaukee, Grand, where there’s only 7 crashes.

Array

What about the two intersections causes such a difference in crashes? Let’s look at some data:

Ogden, Milwaukee, Chicago Halsted, Milwaukee, Grand
Automobile traffic Approx 58,000 cars per day Approx 50,000 cars per day.
Bicycle traffic Not counted, but probably fewer than 3,100 bikes More than 3,100 bikes per day*
Bus traffic Two bus routes Three bus routes
Intersection style Island; three signal cycles No island; one signal cycle

*Notes

Traffic counts are assumed estimates. Counts are taken on a single day, either Tuesday, Wednesday, or Thursday. Bike counts at Halsted/Milwaukee/Grand were actually taken on Milwaukee several hundred feet northwest of the intersection so DO NOT include people biking on Halsted or Grand! This means that more than 3,100 people are biking through the intersection each day.

Intersection style tells us which kind of six-way intersection it is. At island styles you’ll find a concrete traffic island separating the three streets. You’ll also find three signal cycles because there are actually three intersections instead of one, making it a 12-way intersection. Also at these intersections you’ll see confusing instructional signage like, “OBEY YOUR SIGNAL ONLY” and “ONCOMING TRAFFIC HAS LONGER GREEN.”

Here’s a more lengthy description of one of the problems here as well as an extremely simple solution: install a left-turn arrow for northbound Milwaukee Avenue. The entire intersection is within Alderman Burnett’s Ward 27.

Source and method

I can’t yet tell you how I obtained this data or created the map. I’m still working out the specifics in my procedures log. It involved some manual work at the end because in the resulting table that counted the number of crashes per intersection, every intersection was repeated, but the street names were in opposite columns.

Crash data from the Illinois Department of Transportation. Street data from the City of Chicago. Intersection data created with fTools in QGIS. To save time in this initial analysis, I only considered Milwaukee Avenue intersections with streets in the City of Chicago centerline file with a labeled CLASS of 1, 2, or 3.

Tagged with:
 

Plugins for QGIS I use most often.

All of these can be installed automatically by QGIS. Click on Plugins>Fetch Python Plugins. Then search for the plugin, click on its name, and click Install Plugin. Few plugins require a restart.

  • MMQGIS – Great for working with CSV files; also merges layers (even if they have differing attributes); has various other useful functions, including converting string data to float data. Has Voronoi diagram function (takes a long time to process).
  • fTools – Replicates some of the most basic geographic tools in ArcGIS, like Clip, Dissolve, and Reproject. Can also add X/Y values to point attribute tables that are missing them (if you want latitude/longitude, you must reproject into a coordinate reference system first, like WGS84 [EPSG: 4326]). Unfortunately, there’s little information on what each fTools function does. Below are descriptions:
    • Extract Nodes – Create a point at each intersection of vertices.
    • Basic Statistics – Generate arithmetic statistics for fields, same as statistics function in ArcGIS. Great for quickly understanding the extent of values in a field (especially numeric values), like mean, max, min, standard deviation, and number of unique values.
    • Nearest Neighbour Analysis – More details here.
    • Geoprocessing Tools>Dissolve – Combine features based on a shared attribute. For example, all features with an identical STREET_TYPE be combined into a single feature. For example, all “Avenues” will become one feature and all “Boulevards” will become a second feature. Only works on polygon layers.
    • Descrição em português
  • Table Manager
  • Open Layers – Embed Google, Yahoo, Bing, and OpenStreetMap layers in your map. See my example.
Tagged with:
 

Array

A map that focuses on striped bikeways in downtown Chicago.

When you look at your bikeways more abstractly, like in the graphic above, do you see deficiencies or gaps in the network? Anything glaring or odd?

It’s a simple exercise: Open up QGIS and load in the relevant geographic data for your city. For Chicago, I added the city boundary, hydrography and parks (for locational reference), and bike lanes and marked-shared lanes*. Symbolize the bikeways to stand out in a bright color. I had the Chicago Transit Authority stations overlaid, but I removed them because it minimized the “black hole of bikeways” I want to show.

What do you see?

Bigger impact map

This exercise can have more impact if it was visualized differently. You have to be familiar with downtown Chicago and the Loop to fully understand why it’s important to notice what’s missing. It’s an extremely office and job dense neighborhood. It also has one of the highest densities of students in the country; the number of people residing downtown continues to grow. If I had good data on how many workers and students there were per building, I could indicate that on the map to show just how many people are potentially affected by the lack of bicycle infrastructure that leads them to their jobs (or class) in the morning, and home in the evening. I don’t know how to account for all of the bicycling that goes through downtown just for events, like at Millennium and Grant Parks, the Cultural Center, and other theaters and venues.

*If you cannot find GIS data for your city, please let me know and I will try to help you find it. It should be available for your city as a matter of course.

Tagged with: