Tag: opendata

How to make a map of places of worship in Cook County using OpenStreetMap data

The screenshot shows the configuration you need to find and download places of worship in Cook County, Illinois, using the Overpass Turbo website.

If you’re looking to make a map of churches, mosques, synagogues and other places of worship, you’ll need data.

  • The Yellow Pages won’t help because you can’t download that.
  • And Google Maps doesn’t let you have a slice of their database, either.
  • There’s no open data* for this because churches don’t pay taxes, don’t have business licenses, and aren’t required to register in any way

This where OpenStreetMap (OSM) comes in. It’s a virtual planet that anyone can edit and anyone can have for free.

First we need to figure out what tag people use to identify these places. Sometimes on OSM there are multiple tags that identify the same kind of place. You should prefer the one that’s either more accurate (and mentioned as such in the wiki) or widespread.

The OSM taginfo website says that editors have added over 1.2 million places of worship to the planet using amenity=place_of_worship.

Now that we know which tag to look for, we need an app that will help us get those places, but only within our desired boundary. Open up Overpass Turbo, which is a website that helps construct calls to the Overpass API, which is one way to find and download data from OSM.

Tutorial

In the default Overpass Turbo query, there’s probably a tag in brackets that says [amenity=drinking_fountain]. Change that to say [amenity=place_of_worship] (without the quotes). Now change the viewport of the map to show only the area in which you want Overpass Turbo to look for these places of worship. In the query this argument is listed as ({{bbox}}).

The map has a search bar to find boundaries (cities, counties, principalities, neighborhoods, etc.) so type in “Cook County” and press Enter. The Cook County in Illinois, United States of America, will probably appear first. Select that one and the map will zoom to show the whole county in the viewport.

Now that we’ve set the tag to [amenity=place_of_worship] and moved the map to show Cook County we can click “Run”. In a few seconds you’ll see a circle over each place of worship.

It’s now simple to download: Click on the “Export” button and click “KML” to be able to load the data into Google Earth, “GeoJSON” to load it into a GIS app like QGIS, or “save GeoJSON to gist” to create an instant map within GitHub.

*You could probably get creative and ask a municipality for a list of certificates of occupancy or building permits that had marked “religious assembly” as the zoning use for the property.

How many miles of roads are in your ward?

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.

[table id=7 /]

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

Give the CTA a medal, or a pony, for Train Tracker

The Chicago Transit Authority released the Train Tracker API to developers with little fanfare. But it’s some high-quality stuff. At least this guy thinks the documentation is excellent*:

“Dear CTA: please give whoever wrote the Train Tracker API docs a medal, or a pony, or something. Thanks.” Original tweet by cieslak.

I think they got the message. You can bet they asked for the pony.

*I haven’t taken a look at the Train Tracker API documentation, but I did review the Trademark/Branding Guidelines for developers. It’s very clear how you should and shouldn’t use the CTA name and service marks and graphics. I also had a sneak preview in December 2010 of the Train Tracker website, to give user feedback. I was shocked and impressed to find that it worked on my Samsung Slash, a remarkably dumb phone that happens to be able to run Opera Mini (see photo below). The API wasn’t available until June 2011.

Two new beta apps for Chicago geography

I think 2011 is going to be the year of apps for me. I developed one for bikes and one for politics.

Bikes

I made the “Chicago Bike Data Portal” app on Saturday night. It gets your location via the HTML5 geolocation API and loads a list and map of all the reported bike crashes within half a mile. It works on some mobile phones, too (at least Android and iOS). Expect to see more data in the future, like ped and automobile crashes.

Politics

Then on Monday I made an app called, “Who is my Chicago Alderman?” where people can type in their address (or any address) and retrieve the alderman’s name, addresses, and phone numbers. I’ve already identified a problem where the app returns the wrong information for an address. I think this is a problem with the geocoder. Ever since CivicFootprint (a project of Center for Neighborhood Technology) disappeared, the city’s been missing an easy-to-use app for finding alderman. The city clerk’s website takes too long to use and is not as informative.

Other apps I built or worked on

You asked for it, you got it – Chicago bike count data

Note: This post doesn’t have any analysis of the data or report, nor do I make any observations. I think it’s more significant to hear the ideas you have about what you see in the map or read in the data.

A lot of people wanted the Chicago bike crash and injury data overlaid with bike counts data.

In 2009, Chicago Department of Transportation (CDOT) placed automatic bike counting equipment at many locations around the city. It uses pneumatic tubes to count the number of bicyclists (excludes cars) at that point in the street – it counts ALL trips, and cannot distinguish between people going to work or going to school. This is dissimilar from Census data which asks respondents to indicate how they go to work.

Well, good news for you! CDOT today released the bike counts report from data collected in 2009 (just in time). There has been overwhelming response about the bike crash map I published – this shows how rabid the public is for information on their environments (just yesterday someone told me that they switched bike routes based on the crash frequency they noticed on their original route).

The size of the blue dot indicates the bicycle mode share for that count location. Mode share calculated by adding bikes and cars and dividing by bikes.

Get the data

A photo of the EcoCounter counting machine in action on Milwaukee Avenue (this was taken during testing phase, where CDOT compared automatic and manual counts to determine the machine’s accuracy).

How to use this map:

  1. Find a blue dot (count location) in an area you’re interested in.
  2. Zoom into that blue dot.
  3. Click on the blue dot to get the number of bikes counted there.
  4. Then observe the number of purple dots (crashes) near that count location.

What do you see that’s interesting?

What else is coming?

Now let’s hope the Active Transportation Alliance and the Chicago Park District release their Lakefront Trail counts from summer 2010. CDOT may have conducted bicycle counts in 2010 as well – I hope we don’t have to wait as long for that data.

I hope to have a tutorial on how to use GeoCommons coming soon. You should bug me about it if I don’t post it within one week.

Photos of Chicago bike commuters by Joshua Koonce.