champagne anarchist | armchair activist


New Python package for downloading and analysing street networks


The image above shows square mile diagrams of cyclable routes in the area around the Stationsplein in Amsterdam, the Hague, Rotterdam and Utrecht. I made the maps with OSMnx, a Python package created by Geoff Boeing, a PhD candidate in urban planning at UC Berkeley (via).

Square mile diagrams are a nice gimmick (with practical uses), but they’re just the tip of the iceberg of what OSMnx can do. You can use it to download administrative boundaries (e.g. the outline of Amsterdam) as well as street networks from Open Street Map. And you can analyse these networks, for example: assess their density, find out which streets are connections between separate clusters in the network, or show which parts of the city have long or short blocks (I haven’t tried doing network measure calculations yet).

Boeing boasts that his package not only offers functionality that wasn’t (easily) available yet, but also that many tasks can be performed with a single line of code. From what I’ve seen so far, it’s true: the package is amazingly easy to use. All in all, I think this is a great tool.

DuckDuckGo shows code examples

Because of Google’s new privacy warning, I finally changed my default search engine to DuckDuckGo.[1] So far, I’m quite happy with it. I was especially pleased when I noticed they sometimes show code snippets or excerpts from documentation on the results page.

Apparently, DDG has decided that it wants to be «the best search engine for programmers». One feature they’re using are the instant answers that are sometimes shown in addition to the ‘normal’ search results. These instant answers may get their contents from DDGs own databases - examples include cheat sheets created for the purpose - or they may use external APIs, such as the Stack Overflow API. Currently, volunteers are working to improve search results for the top 15 programming languages, including Javascript, Python and R.

One could argue that instant answers promote the wrong kind of laziness - copying code from the search results page rather than visit the original post on Stack Overflow. But for quickly looking up trivial stuff, I think this is perfect.

  1. I assume the contents of the privacy warning could have been reason to switch search engines, but what triggered me was the intrusive warning that Google shows in each new browsers session - basically punishing you for having your browser throw away cookies.  ↩

Amsterdam heeft ruimte voor nog eens 2,1 miljoen fietsenrekken


Amsterdam kampt met een hardnekkig tekort aan fietsenrekken. Fietsprofessor Marco te Brömmelstroet voert echter aan dat dit een kwestie is van keuzes maken: op de plek van vier geparkeerde auto’s kan je makkelijk 30 fietsenrekken kwijt.

Amsterdam is een compacte stad waar ruimte schaars is. Een belangrijk doel van het gemeentebestuur is om meer ruimte te creëren voor voetgangers en fietsers, maar ook voor openbaar groen.

Toevallig heeft Amsterdam onlangs open data gepubliceerd over parkeervakken voor straatparkeren. De gegevens bevestigen wat we eigenlijk al wisten: parkeerplaatsen nemen enorm veel publieke ruimte in beslag. De straten van Amsterdam zijn bezaaid met maar liefst 265.225 parkeervakken. Als je de parkeerplaatsen met een bord (oplaadplekken, autodaten, etcetera) buiten beschouwing laat, dan zijn het er nog altijd 260.834.

Als je aanneemt dat elke parkeerplek ruimte zou kunnen bieden aan zeker 8 fietsen, dan is er ruimte voor 2,1 miljoen extra fietsenrekken. Natuurlijk ga je niet alle parkeervakken verwijderen en volbouwen met fietsenrekken, maar het illustreert de keuzeruimte die er is bij de inrichting van de openbare ruimte.

Detailkaart | Verantwoording

Amsterdam has room for another 2.1 million bicycle racks


Amsterdam has a persistent shortage of bicycle racks. Bicycle professor Marco te Brömmelstroet argues that this is really a matter of making choices: the space occupied by four parked cars could easily accommodate 30 bicycle racks.

Amsterdam is a compact city where space is limited. An important goal of the city administration is to create more room for pedestrians and cyclists, but also for green areas.

It so happens that the city of Amsterdam has recently published open data on on-street parking spaces. The data confirms what we already knew: parking spaces for cars occupy a huge amount of public space. The streets of Amsterdam are littered with as many as 265,225 parking spaces. If you exclude the ones with signs (spaces for charging car batteries; car sharing; etcetera), there are still 260,834 of them.

Assuming that each of them could accomodate at least 8 bicycle racks, there’s room for another 2.1 million bicycle racks. Now you probably wouldn’t want to remove all parking spaces and replace them with bicycle racks, but it does illustrate some of the choices that are available regarding the use of public space.

Map detail here.


The open data on on-street parking spaces is available in WFS format which is meant for creating maps but can also be used for downloading data - here’s a Python script that will do the job. I set the location of the parking spaces to the centre of the surrounding envelope.

I would have liked to display the data on an interactive map using Leaflet and D3js, but I’m afraid the quarter million data points would crash the browser. Instead I used OSM map data in combination with Qgis to display the parking spaces. Unfortunately, this means you can’t zoom in.

As for the parking space to bicycle rack ratio: I’m assuming a typical parking space takes up 12 to 14 m2. Cyclists’ organisation Fietsersbond has calculated that regular bicycle racks take up between 0.84 and 1.18 m2 per bicycle. The city of Amsterdam is a bit more conservative and estimates that a bicycle rack takes up about 1.5 m2, including the room needed to remove the bicycle. This suggests that the number of bicycle racks that could be created per parking space lies somewhere between 8 and 9.3.

Update 3 July 2016 - The city of Nijmegen reckons it can fit as many as 10 bicycle racks on a parking space.
Update 31 January 2017 - And the city of New York needs about nine parking spaces to accomodate 69 city bikes.
And a follow-up (in Dutch).

Assignment 1-3

A little background: I’m using the Outlook on Life Surveys dataset and I’m interested in the relation between union membership and political participation (background here). The third assignment is similar to the second one, only we’re required to do some data management before outputting the data. Therefore, I’ll submit an adapted version of the programme and blogpost of the previous assignment.

The output’s supposed to be ‘interpretable (i.e. organized and labeled)’. For those who are logged in to the course website, I refer to this forum post disucssing how I interpreted this requirement.

In terms of data management, I’ll perform the following steps: first recode ‘refused’ to NaN (not required for the first variable PPWORK, because it has no missing values) and recode the answers to labels (e.g. 1 = ‘Yes’). Next, I’ll create a secondary variable which indicates whether respondents have engaged in any of the four types of political participation discussed below.

The programme itself is posted here. Below I’ll discuss some of the output. For the sake of convenience, I’ll only show percentages (the raw counts can be obtained by running the programme). First, the current employment status of respondents.

PPWORK: Current Employment Status
Not working - retired                           21.011334
Not working - on temporary layoff from a job     1.264167
Not working - looking for work                  10.854403
Not working - disabled                           8.456844
Not working - other                              6.451613
Working - self-employed                          6.190061
Working - as a paid employee                    45.771578
dtype: float64

One of the variables I’m interested in, is union membership. My understanding of the American situation is that union membership is often dependent on whether your workplace is organised (by contrast, in the Netherlands it’s not uncommon for unemployed or retired people to be union members). For that reason, it makes sense to look specifically at respondents who are working as paid employees. (The fact that union membership is measured at the household level complicates matters but that doesn’t change my preference to focus on paid employees.)

1,050 respondents (46%) are paid employees. This would seem to be a sufficiently large group for the purposes of the analyses I plan to do. In the programme, I created at subset of respondents who indicated they are working as paid employees. All output below is based on this subset.

Next, let’s take a look at the numbers for the variable on union membership (as indicated, at the household level).

W1_P8: Does anyone in your household currently belong to a union?
NaN     1.142857
No     78.380952
Yes    20.476190
dtype: float64

Within the subset of respondents with paid employment, little over 20% indicate that at least one person in their household is a union member. This compares to a union density of 11.1% among wage and salary workers in the US according to the Bureau of Labour Statistics.

Some of that difference can be explained by the fact that the 20% figure will include some respondents who aren’t union members themselves but who have someone in their household who is. On the other hand, the BLS is a bit more persistent in assessing union membership, and would likely classify some people as union members who wouldn’t be classified as such in the OOL surveys.[1] All in all, I’m inclined to say the 20% figure in the OOL surveys is higher than expected and that there is a possiblity that the survey sample is in some way biased towards union members.

And finally the political participation measures.

W1_L4_A: [Contacted a public official or agency ] Please indicate if you have done any of the following activities in the last 2 years.
NaN     2.190476
No     74.095238
Yes    23.714286
dtype: float64
W1_L4_B: [Attended a protest meeting or demonstration ] Please indicate if you have done any of the following activites in the last 2 years.
NaN     2.190476
No     90.571429
Yes     7.238095
dtype: float64
W1_L4_C: [Taken part in a neighborhood march ] Please indicate if you have done any of the following activites in the last 2 years.
NaN     2.095238
No     93.047619
Yes     4.857143
dtype: float64
W1_L4_D: [Signed a petition in support of something or against something ] Please indicate if you have done any of the following activites in the last 2 years.
NaN     2.380952
No     58.190476
Yes    39.428571
dtype: float64

Respondents are more likely to have signed a petition or contacted an offical than to have hit the streets. This is as expected.

I’ve created a secondary variable indicating whether respondents have participated in any of the discussed forms of political participation. Respondents who have answered ‘Yes’ to any of the four political participation questions will be assigned a value ‘Yes’; those who have answered ‘No’ to all four questions will be assigned a value ‘No’ and those who have not answered ‘Yes’ to any of the questions but who have refused to answer at least one of the questions will be treated as missing.

ANY: Respondent has engaged in any of the four forms of political participation in the last 2 years
NaN     2.190476
No     50.952381
Yes    46.857143
dtype: float64

The frequency table shows that almost half the respondents have engaged in any of the discussed forms of political participation in the last 2 years.

Finally a word on missing values. For all variables considered here, the percentage ‘refused’ is below 2.5%. This would seem sufficiently low not to expect any problems arising from this.

PS One of the students who reviewed my first assigment suggested I include ‘canvassing’ as a measure of political participation, which seems to make sense. Unfortunately the dataset doesn’t seem to include this aspect, but there are variables on other types of political participation that I may add in the future.

  1. «Employed wage and salary workers are classified as union members if they answer “yes” to the following question: On this job, are you a member of a labor union or of an employee association similar to a union? If the response is “no” to that question, then the interviewer asks a second question: On this job, are you covered by a union or employee association contract? If the response is “yes,” then these persons, along with those who responded “yes” to being union members, are classified as represented by a union. If the response is “no” to both the first and second questions, then they are classified as nonunion.»  ↩