When I stumbled across Geoff Boeing’s street network orientation visualizations for 25 major cities in the United States and 100 cities around the World I made a note for myself to figure out how to (1) create something similar in R, and (2) do it for Canadian cities. Using polar histograms to demonstrate how a city’s streets are oriented (in terms of compass bearings) is an interesting way to visualize the general pattern/structure of a city.

Boeing’s posts and his article published in Applied Network Science (PDF) were really helpful for working out how to analyze and plot the street-level data. And this post demonstrating how to use OpenStreetMap data via the osmdata package, was essential for getting everything coded in R.

I combined the concepts/instructions from those articles and was able to create a set of polar histograms for selected major Canadian cities. I chose 16 cities: the ten provincial capitals, the non-capital largest city (for the provinces in which the largest city is not the capital), and then Ottawa, Canada’s capital. 

For each city I pulled the OpenStreetMap data (using default bounding box parameters) and used it to analyze the streets’ bearings as Boeing described in his published article. Unlike the OSMnx software he used, the bearings of the streets are not given by osmdata. So to determine each street’s bearing I relied on the geosphere package, specifically submitting the start point and end point of the street (as defined in the set of nodes given in the OpenStreetMap data) to the bearing function. Doing it this way ignores the subtleties of mid-street curves or turns, but captures the overall bearing one would have to take to get from one end of the street to the other “as the crow flies”. I then added the reciprocal of each street’s bearing to account for the fact that streets point in both directions. For instance, if a street has a bearing of 45° then I add a bearing of 225°. In the analysis, each street is weighted by its length (Haversine distance from the start point to end point). This provides a cleaner representation of the city’s overall orientation. Essentially, I didn’t want Toronto’s Yonge St. and Mill St. to hold equal sway on the overall representation of the city. All the bearings (and reciprocals) for all the streets in a city are then plotted as a polar histogram with 10° bins (centered on the 10s: 0, 10, 20, …, 90, 180, 270).

So how well do these major Canadian cities follow the cardinal north-south-east-west orientation? Some more than others:

(click image to embiggen)

The direction of the bars in the polar histograms shown above represent the bearings of the streets and the length (height) of the bar represents the proportion of streets with those bearings. The concentric circles within each plot are in increments of 2%. So if a bar reaches up to the second circle it means that 4% of the streets in the city are oriented at that bearing. You can see that in, for example, Edmonton the streets are primarily oriented along the orthogonal N-S-E-W layout, whereas in somewhere like Fredericton, where I currently live, things are angled from that layout:

(click image to embiggen)

Most cities have a pretty strong orthogonal layout, even if it deviates from the cardinal directions, but places like St. John’s and Halifax are exceptions. The streets in those cities are much more evenly distributed around the compass. Here’s Halifax:

(click image to embiggen)

You can see that Halifax has areas that follow an orthogonal grid, but these grids are not aligned with each other, which explains the wider distribution of street orientations in the city. Other than St. John’s, Halifax is the city that is least organized along one primary orthogonal grid. Here are all the city-histograms again, but rather than being ordered alphabetically they are ordered by the extent of their gridness, as determined by longest bar (from Vancouver to St. John’s):

(click image to embiggen)

It is worth noting that my use of default bounding boxes for the cities affects things. This means that the comparisons are not necessarily apples-to-apples. In some cases wider areas are included and so the volume of streets can impact the proportions in the histograms. For example, Montreal is much less ordered than I expected it to be, but I suspect that is because a rather large area of streets is included

Regardless of the imperfect comparisons of street networks, this was a fun way to explore some Canadian cities and develop tools for analyzing some new (to me) data in R. I also took time to look at the characteristics of cities not included in the figures above (e.g., Thunder Bay) and developed code to turn the map-with-histogram images into decent looking posters. You can find the code for doing so here.