Category: Tutorial

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.

The best way to store directions on your smartphone is low tech

map of southern illinois as seen in the OsmAnd app

OsmAnd has great offline mapping features but it was tedious to ensure I had all of the maps at the desired zoom levels for the three-city bike ride in southern Illinois (pictured).

My friend is going to pick up a unique bicycle in Ohio and ride it back to Chicago. He designed a good route on Google Maps but now he needs to save it to his smartphone so he doesn’t have to constantly load directions and use data and waste battery life.

I gave him these instructions:

The best way to get a mobile view of the route is to use the Google Maps print feature and save it as a PDF. Then transfer that PDF to your phone through the Dropbox app. Then, in the Dropbox app, mark the PDF file as a favorite so that it’s stored offline, onto the phone.

There’s probably an app that can do what he wants, but I don’t know about it. There are hundreds of “maps” apps to sort through in each the App Store for iOS and the Play Store for Android.

In fact, I’ve downloaded OsmAnd, an offline maps app, for my Android tablet. I installed it and tried to learn how to use it in order to follow a downstate, intercity bike camping route. The app, though, required that you zoom in to each part of the map you wanted to store and then press “download”.

 

I spent 30 minutes downloading parts of the map, manually panning to the next section, before I decided to instead obtain one of the Illinois Department of Transportation’s regional bike maps and just draw it on there and write out a “cue sheet” (turn by turn directions).

How to ascertain the area of Chicago beach parking lots to find the largest one

This tutorial is a direct response to a question about which Chicago beach has the largest parking lot. Matt Nardella of Moss Design, in a response to a Twitter-based conversation about Alderman Cappleman’s suggestion that perhaps Montrose beach has too much parking, researched on Wikipedia to find the answer. This is where it said that Montrose beach has the largest parking lot of any of Chicago’s 27 beaches.

Now we’re going to try and prove which beach has the largest associated parking lot.

This tutorial will teach how you to (1) display Chicago beaches, (2) download data held in OpenStreetMap, (3) find the parking lots within the OpenStreetMap data, (4) find the parking lots near the beaches, and (5) calculate each parking lot’s area (in square feet). You can use this tutorial to accomplish any one of these three tasks, or the same tasks but on a different part of OpenStreetMap data (like the area of indoor shopping malls).

You’ll need the QGIS software before starting. You’ll also need at least 500 MB of free space. Start a project folder called “Biggest Parking Lots in Chicago” and make two more folders, within this folder, called “origdata” and “data”.

First, let’s get some data about beaches

Since we only want to know about the parking lots near Chicago beaches we need to get a dataset that locates them. This data is presumably within the same OpenStreetMap extract we’re waiting for, but it’s best to go to the most reliable source.

  1. Download the Parks – Facilities & Features shapefile from the City of Chicago open data portal. I’ve already verified that it has all the beaches (as points).
  2. Open the parks shapefile in a new document in QGIS (call it “map01a.qgs”). You might not see the data so right-click the parks layer and select “Zoom to layer extent”.
  3. Filter out all the points that aren’t beaches by using the query builder. Right-click the layer and select “Filter…” and input this filter expression: “FACILITY_N” = ‘BEACH’
  4. Your map will now show 26 points along an invisible lakefront and then the beach at Humboldt Park.
  5. For the rest of this tutorial we’ll reference the beaches layer as ParkFacilities.

Second, let’s get some data from OpenStreetMap

The easiest way to grab data from OpenStreetMap is by using QGIS, a free, open source desktop GIS application that has myriad plugins that match the capabilities of the heavyweight ESRI ArcGIS line of software. We can download OpenStreetMap data straight into QGIS.

  1. Click on the Vector menu and select OpenStreetMap>Download data.
  2. We want as much data as will cover the beaches information so in the Extent section of the dialog box choose “From layer” and select the beaches layer (called ParkFacilities).
  3. Browse to the “origdata” folder you created in the first task and choose the filename “chicago.osm”.
  4. Click OK and watch the progress meter tell you how much data you’ve downloaded from OpenStreetMap.
  5. Once it’s completed downloading, click “Close”. Now we want to add this data to our map.
  6. Drag the chicago.osm file from your file system into the QGIS Layers list. A dialog box will appear asking which layers you want to add.
  7. Select the layer that has the type “MultiPolygon”. This represents areas like buildings and parking lots.

Third, display the OpenStreetMap data and eliminate everything but the parking lots

We only want to compare parking lots in this dataset with beaches in the previous dataset so we need to eliminate everything from the OpenStreetMap data that’s not a parking lot. Since OSM data depends on tags we can easily select and show all the objects where “amenity” = “parking”.

  1. Filter out all the polygons that aren’t parking lots by using the query builder. Right-click the layer and select “Filter…” and input this filter expression: “amenity” = ‘parking’. Hopefully all the parking lots have been drawn so we can analyze a complete dataset!
  2. Your map will now show little squares, rectangles, and myriad odd shapes that represent parking lots around Chicagoland. (Most of these have been drawn by hand.) It should look like Image XXX.
  3. Since this data is stored in a projection with the codename of EPSG:3435 and the OpenStreetMap data is stored with codename of EPSG:4326 we need to convert the beaches to match the beaches (because we’re going to be using feet as a  measuring distance instead of degrees).
  4. Right-click the layer and select “Save As…” and choose the format “ESRI Shapefile”. Then click the top Browse button and select a location on your hard drive for the converted file.
  5. For “CRS” choose “Selected CRS”. Then click the bottom Browse button and search for the EPSG with the codename 3435. Select the checkbox named “Add saved file to map” so the new layer will be immediately added to our map.

Fourth, select all the parking lots near a beach

This task will select all the parking lots near the beaches. I chose 2,000 feet but you could easily choose a different distance. You might want to measure on Google Earth some minimum and maximum distances between beaches and their respective, associated parking lots.

(This task is easier using PostGIS which has a ST_DWithin function to find objects within a certain distance because we can avoid having to create the buffer in QGIS.)

  1. Create a 2,000 feet buffer. Select Vector>Geoprocessing tools>Buffer.
  2. In the Buffer(s) dialog box, select ParkFacilities (which has your beaches) as the “Input vector layer”. Choose a distance of 2000 (the units are pre-chosen by the projection and since we’re using a projection that’s in feet, the distance unit will be feet).
  3. Browse to your project folder’s “data” folder and save the “Output shapefile” as “beaches buffer 2000ft.shp”.
  4. Click “Add results to canvas” and then click OK.
  5. Double check that 2,000 feet was enough to select the parking lots. In my case, I see that the point representing Montrose beach was further than 2,000 feet away from a parking lot.
  6. Let’s do it again but with 3,000 feet this time, and saving the “Output shapefile” as “beaches buffer 3000ft.shp”.
  7. This time it worked and the nearest parking lots are now in the 3,000 feet radius buffer. You can see in Image XXX how the two concentric circles stretch out from the beach point towards the parking lots.

We’re not done. We’re next going to use our newly created 3,000 feet buffers to tell us which parking lots are in them. These will be presumed to be our beach parking lots.

  1. Use the “Select by location” tool to find the beaches that intersect our 3,000 feet buffers. Select Vector>Research Tools>Select by location.
  2. Follow me: we want to select features in parking 3435 [our parking lots] that intersect features in beaches buffer 3000ft [our beaches]. We’ll modify the current selection by creating a new selection so that we don’t accidentally include any features previously selected.
  3. You’ll now see a bunch of parking lots turn yellow meaning they are actively selected.
  4. Let’s save our selected parking lots as a new file so it will be easier to analyze just them. Right-click “parking 3435” and select “Save Selection As…” (it’s important to choose “Save Selection As” instead of “Save As” because the former will save just the parking lots we’ve selected).
  5. Save it as “selected parking 3435.shp” in your “data” folder. The CRS should be EPSG:3435 (NAD83 Illinois StatePlane East Feet). Check off “Add saved file to map” and click OK.
  6. Turn off all other layers except ParkFacilities to see what we’re left with and you’ll see what I show in Image XXX.

Fifth, let’s calculate

Calculating the area is probably the easiest part of this tutorial.

  1. Close all attribute tables you may have opened.
  2. Select Vector>Geometry Tools>Export/Add geometry columns and choose “selected parking 3435” as your input vector layer.
  3. Leave all other options as-is and press OK. When told about how QGIS can’t access something simultaneously, choose “Yes”.
  4. QGIS should have told you that “selected parking 3435” has been updated. Right-click the layer and choose “Open Attribute Table”.
  5. Scroll to the far right and you’ll see a new column called AREA. This represents the parking lot’s area in square feet.
  6. Click on the AREA column heading to sort it from smallest to largest. Scroll to the bottom of the list and you’ll find the parking lot with the largest area. Double check – is it near a beach?

Conclusion

With my analysis, and with the data available from OpenStreetMap when I created this tutorial, there are three abnormally large parking lots:

  1. A linear lot near the Lincoln Park Zoo and North Avenue beach (6.8 acres)
  2. A curving lot near Montrose Beach (4.75 acres)
  3. An irregularly shaped lot near Montrose Beach (4.5 acres)

There’s one major caveat in this analysis and that’s the missing parking lots on beaches south of Navy Pier. This means that no one has drawn them into OpenStreetMap so it’s time to start editing!

How many cars are in Rogers Park?

There are a gazillion cars in Rogers Park, and there’s no place to park them. That’s the declaration you would gather if you listen to “Lakefront Car Tower” (a parking garage) proponents, including the 49th ward alderman, Joe Moore.

The parking problem is so bad in Rogers Park that a parking garage at Sherwin Avenue and Sheridan Road that would provide less than 100 overnight parking spaces to the public was actually sent from Asphaltia, the god of car parks. It’s so bad that “[m]any car owners find themselves stuck in their home at night” – yes, the alderman really published that on his website – because they find a parking space on Friday night and can’t move the car until Monday morning. The horror of using your feet, pedals, the bus, the train, car sharing, paratransit, or a Segway!

(I’d love to get into parking pricing policy now, but I’ll just leave you with this: of course there is going to be a demand problem when the supply of publicly-owned on-street parking costs $0 per year.)

This post is actually a tutorial on how to use United States Census data to find how many cars are in the neighborhood of Rogers Park, not a laugh about Asphaltia’s teachings.

Let’s begin! Continue reading

How to convert bike-share JSON data to CSV and then to shapefile

Update January 4, 2013: The easiest way to do this is to use Ian Dees’s Divvy API as it outputs straight to GeoJSON (which QGIS likes). See below.

For Michael Carney’s Divvy bike-share stations + Census tract + unbanked Chicagoans analysis and map he needed the Divvy station locations as a shapefile. I copied the JSON-formatted text of the Divvy real-time station API, converted it to CSV with OpenRefine, and then created a shapefile with QGIS.

Here’s how to create a shapefile of any bike-share system that uses hardware from Public Bike System Co based on Montréal and is operated by Alta Bicycle Share (this includes New York City, Chattanooga, Bay Area, Melbourne, and Chicago): Continue reading