Street network figure-ground diagrams, à la Allan Jacobs's Great Streets

Use OSMnx to download square-mile city street networks and visualize them as figure-ground diagrams. Discussed in this blog post.


In [1]:
import osmnx as ox
from IPython.display import Image
%matplotlib inline
ox.config(log_file=True, log_console=True, use_cache=True)

In [2]:
# configure the inline image display
img_folder = 'images'
extension = 'png'
size = 350
dpi = 90

Part I: create diagrams by passing in lat-long points


In [3]:
place = 'sf'
point = (37.793897, -122.402189)
fig, ax = ox.plot_figure_ground(point=point, filename=place, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[3]:

In [4]:
place = 'portland'
point = (45.517309, -122.682138)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[4]:

In [5]:
place = 'irvine'
point = (33.694981, -117.841375)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', default_width=6, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[5]:

In [6]:
place = 'rome'
point = (41.901336, 12.471831)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='all', default_width=3.3, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[6]:

In [7]:
place = 'barcelona-gothic'
point = (41.382850, 2.174192)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='all', default_width=3.3, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[7]:

In [8]:
place = 'nyc'
point = (40.757920, -73.983393)
fig, ax = ox.plot_figure_ground(point=point, filename=place, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[8]:

In [9]:
place = 'los-angeles'
point = (34.047404, -118.253146)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[9]:

In [10]:
place = 'paris'
point = (48.873702, 2.294136)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', default_width=3.3, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[10]:

In [11]:
place = 'dc'
point = (38.907919, -77.036552)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[11]:

In [12]:
place = 'dubai1'
point = (25.203143, 55.270007)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[12]:

In [13]:
place = 'dubai2'
point = (25.056565, 55.207924)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[13]:

In [14]:
place = 'shanghai'
point = (31.234696, 121.481170)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[14]:

In [15]:
place = 'osaka'
point = (34.694834, 135.484761)
fig, ax = ox.plot_figure_ground(point=point, filename=place, default_width=3, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[15]:

In [16]:
place = 'boston'
point = (42.362084, -71.057267)
fig, ax = ox.plot_figure_ground(point=point, filename=place, default_width=3.3, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[16]:

In [17]:
place = 'sacramento'
point = (38.587193, -121.372872)
fig, ax = ox.plot_figure_ground(point=point, filename=place, default_width=5, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[17]:

Part II: Create diagrams for any city, by just passing in a place name


In [18]:
place = 'Atlanta, Georgia, USA'
fig, ax = ox.plot_figure_ground(address=place, filename=place, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[18]:

In [19]:
place = 'Denver, Colorado, USA'
fig, ax = ox.plot_figure_ground(address=place, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[19]:

In [20]:
place = 'Sao Chingcha, Bangkok, Thailand'
fig, ax = ox.plot_figure_ground(address=place, filename=place, default_width=3, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[20]:

In [21]:
place = 'Medina, Tunis, Tunisia'
fig, ax = ox.plot_figure_ground(address=place, filename=place, network_type='all', default_width=3.3, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[21]:

In [22]:
place = 'Times Square, New York, NY, USA'
fig, ax = ox.plot_figure_ground(address=place, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[22]:

In [23]:
place = 'East Village, New York, NY, USA'
fig, ax = ox.plot_figure_ground(address=place, filename=place, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[23]:

In [24]:
place = 'Charlotte, North Carolina, USA'
fig, ax = ox.plot_figure_ground(address=place, filename=place, network_type='drive', dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[24]:

Part III: Configure street width pixels

OSMnx uses the highway OSM tag to ascribe street widths, in pixels. You can pass in a dictionary of street widths to override the default values. Any street type that does not appear as a key in the street widths dict falls back onto the default_width value.


In [25]:
street_widths = {'footway' : 0.5,
                 'steps' : 0.5,
                 'pedestrian' : 0.5,
                 'path' : 0.5,
                 'track' : 0.5,
                 'service' : 2,
                 'residential' : 3,
                 'primary' : 5,
                 'motorway' : 6}
place = 'sf-custom'
point = (37.793897, -122.402189)
fig, ax = ox.plot_figure_ground(point=point, filename=place, network_type='all', street_widths=street_widths, dpi=dpi)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[25]:

In [ ]: