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):

  1. Download, install, and open OpenRefine – it opens in your default web browser. Click “Create Project” and then click the “Clipboard” tab.
  2. Copy the Divvy JSON text and paste it into the text box. Then click “Next”.
  3. OpenRefine then asks you to click on the first row/record of the JSON text. Hover your mouse over the first “{” (curly bracket) after “stationBeanList” (see screenshot 1).
  4. OpenRefine then gives you a preview table of your data after you select the first row/record. Give you project a name like “Divvy_2013-10-09 10:49:02 PM” (the timestamp at which you copied the data).
  5. Edit two column names to ease importing the data into QGIS. Rename your latitude column from “__anonymous__ – latitude” to “latitude” and your longitude column from “__anonymous__ – longitude” to “longitude”. QGIS will recognize columns with these names and select them for you automatically when you import the upcoming CSV file.
  6. Since OpenRefine saves as you go, you can immediately export and download this dataset as a CSV. Click on Export>Comma-separated value. The file downloads automatically to your browser’s default downloads directory.
  7. Open QGIS. In a new or existing project, click Layer>Add Delimited Text Layer… and click “Browse” to find your downloaded CSV file.
  8. QGIS will automatically identify your X and Y columns, longitude and latitude respectively. Click OK to accept all default settings.
  9. Now QGIS wants to know which projection system it should use to read these data. Select WGS84 (EPSG:4326) and click OK. You should now see a lot of dots on the screen.
  10. Convert this layer to a shapefile by right-clicking on the layer in the Layers box and selecting “Save As…”. Choose “ESRI Shapefile” as the format and click “Browse” next to the “Save as” text box to find a place on your computer to store the file that QGIS will create. Leave CRS as “Layer CRS” and click OK.

You’re done.

Screenshots

Screenshot 1: In OpenRefine, showing you which row/record to click to tell where OpenRefine should start reading. 

Screenshot 2: In QGIS, showing you which primary options should be selected when you import a CSV file. 

Screenshot 3: In QGIS, showing you which secondary options (about project) should be selected when you import a CSV file. 

Screenshot 4: In QGIS, showing all 288 of the Divvy bike-sharing stations in Chicago. You can spot some natural parts, like Northerly Island, 31st Street Beach, and Montrose Beach and Harbor. 

This was cross-posted to Web Map Academy.

Method 2

There’s a second, slightly easier method of turning the Divvy data into a shapefile, and that’s by converting it to GeoJSON instead of CSV. Find the new tutorial on Web Map Academy.