Your first walkability map

The quickest way to feel what Close gives you: read one block’s travel times, map the groceries around it, then draw how far you can walk from it. The example city is Providence, Rhode Island.

Running this tutorial uses about 90 tokens.

Set up

Build a client, then read what you need from the free catalog.

from closecity import Client
import matplotlib.pyplot as plt

close = Client("ck_live_your_key")   # use your own key here
types = close.destination_types()
grocery = types.loc[types["label"] == "grocery_stores", "dest_type_id"].iloc[0]

downtown = close.places("Providence").iloc[0]

Read one block’s travel times

Pick a block and ask how long it takes to walk to each kind of amenity. The result is a small table, one row per category.

summary = close.block_summary("440070008001068", mode = "walk")
summary[["dest_type_id", "travel_time"]].head()
dest_type_id travel_time
0 1 10.0
1 5 26.0
2 6 22.0
3 7 10.0
4 27 3.0

Map the groceries nearby

A radius search returns points, ready to map.

groceries = close.pois_search(lat = downtown["lat"], lon = downtown["lon"],
                              radius_m = 1200, type = grocery)
groceries.plot(color = "#058040", markersize = 20)
<Axes: >
../_images/0db8673fdd51b241f31f5540791280a58247dd179737c9aa8d117cc3a023486a.png

Draw how far you can walk

An isochrone is the headline map: the area you can reach on foot in 10, 20, and 30 minutes. The contours come back largest first, so drawing them in order paints the nearer times on top.

rings = close.isochrone(block = "440070008001068", mode = "walk",
                        direction = "from", contours = [10, 20, 30])
rings.plot(column = "contour", cmap = "YlGnBu_r", legend = True,
           edgecolor = "white", linewidth = 0.5)
<Axes: >
../_images/8334bc276d7d39f8d8958a51f213a6518556289176930c892746358779802603.png

Walk versus transit

The same block, the same 30-minute budget, two modes side by side. It is the clearest way to see what the bus buys you.

walk = close.isochrone(block = "440070008001068", mode = "walk",
                       direction = "from", minutes = 30)
transit = close.isochrone(block = "440070008001068", mode = "transit",
                          direction = "from", minutes = 30)

fig, (left, right) = plt.subplots(1, 2, figsize = (10, 5))
walk.plot(ax = left, color = "#058040")
left.set_title("Walk, 30 min")
transit.plot(ax = right, color = "#202a5b")
right.set_title("Transit, 30 min")
Text(0.5, 1.0, 'Transit, 30 min')
../_images/f7d5c109e0b867d9daad3bb704d434e255297547332fac68dc5d08a21709e49d.png

Where to next