Building footprint (plus street network) figure-ground diagrams

Use OSMnx to download OpenStreetMap building footprints and visualize them as figure-ground diagrams.


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

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

Building footprints within the city limits of Piedmont, California


In [3]:
gdf = ox.buildings_from_place(place='Piedmont, California, USA')
gdf_proj = ox.project_gdf(gdf)
fig, ax = ox.plot_buildings(gdf_proj, bgcolor='#333333', color='w', 
                            save=True, show=False, close=True, filename='piedmont_bldgs', dpi=90)
Image('{}/{}.{}'.format(img_folder, 'piedmont_bldgs', extension), height=size, width=size)


Out[3]:

In [4]:
# save as a shapefile
gdf_save = gdf.drop(labels='nodes', axis=1)
gdf_save.to_file('data/piedmont_bldgs')

One and a half square kilometers near the Arc de Triomphe


In [5]:
point = (48.873446, 2.294255)
dist = 612
gdf = ox.buildings_from_point(point=point, distance=dist)
gdf_proj = ox.project_gdf(gdf)
bbox = ox.bbox_from_point(point=point, distance=dist, project_utm=True)
fig, ax = ox.plot_buildings(gdf_proj, bgcolor='#333333', color='w', figsize=(4,4), bbox=bbox,
                            save=True, show=False, close=True, filename='paris_bldgs', dpi=150)
Image('{}/{}.{}'.format(img_folder, 'paris_bldgs', extension), height=size, width=size)


Out[5]:

Street network + building footprints: square-mile visualizations


In [6]:
# helper funcion to get one-square-mile street networks, building footprints, and plot them
def make_plot(place, point, network_type='drive', bldg_color='orange', dpi=90,
              dist=805, default_width=4, street_widths=None):
    gdf = ox.buildings_from_point(point=point, distance=dist)
    gdf_proj = ox.project_gdf(gdf)
    fig, ax = ox.plot_figure_ground(point=point, dist=dist, network_type=network_type, default_width=default_width,
                                    street_widths=street_widths, save=False, show=False, close=True)
    fig, ax = ox.plot_buildings(gdf_proj, fig=fig, ax=ax, color=bldg_color, set_bounds=False,
                                save=True, show=False, close=True, filename=place, dpi=dpi)

In [7]:
place = 'portland_buildings'
point = (45.517309, -122.682138)
make_plot(place, point)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[7]:

In [8]:
place = 'nyc_buildings'
point = (40.757920, -73.983393)
make_plot(place, point)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[8]:

In [9]:
place = 'richmond_district_buildings'
point = (37.781999, -122.472501)
make_plot(place, point)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[9]:

In [10]:
place = 'port_au_prince_buildings'
point = (18.522240, -72.347607)
make_plot(place, point, network_type='all', default_width=1, street_widths={'secondary':3})
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Self-intersection at or near point -72.353368904649884 18.529025710808554
Self-intersection at or near point -72.354513248257902 18.529361599607206
Self-intersection at or near point -72.3538914025645 18.529385636237887
Self-intersection at or near point -72.345044782282102 18.52757847807688
Self-intersection at or near point -72.341870121131635 18.528016052697783
Out[10]:

In [11]:
place = 'monrovia_liberia_buildings'
point = (6.340236, -10.747255)
make_plot(place, point, network_type='all', default_width=2, street_widths={'primary':6})
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)


Out[11]:

In [ ]: