How do New Yorkers Commute Between Boroughs?

Anna Stokes
Data Mining the City
3 min readOct 4, 2017

For this week I visualized the 2009–2013 American Community Survey’s Journey to Work data set using interactivity, strings/text, and an image. I cleaned the data to only display relevant data for commuters who live and work in New York City, and who(if they drive) may utilize one of the East River Bridges (as the goal of my eventual mid-term project will be to correlate this data to data on income and transit access in order to visualize who will really pay for the proposed congestion pricing scheme which would implement tolls on these bridges). I then visualized it in a bar chart which depicts how many commuters travel from the same place, to the same place, and by the same mode. All relevant information to each bar is displayed in text on the bottom of the page when you hover of the bar with the mouse. To make it easier to perceive which bar you’re looking at I also added a guideline attached to your mouse. Lastly, for those unfamiliar with NYC’s boroughs I added a reference map in the right hand corner.

Some things I’d like to learn how to change:

  • The transit advocate in me LOVES how the public transit bars dwarf other modes but I’d like to figure out a way to scale the bars better so that you can actually see some of the smaller numbers
  • It would be cool if the context map could light up in some way (maybe highlighting the origin, destination, with an arrow in-between) as well.
import csv
def setup():
size(645, 750)
#this is the context map image setup
global img
img = loadImage("contextmap.gif")

#open .csv
with open("JourneytoWork_Exfor10.4.csv") as f:
reader = csv.reader(f)
header = reader.next() # Skip the header row.

#define a new name for your new list
global origins
origins = []

global destinations
destinations = []

global modes
modes = []

global workers
workers = []

for row in reader:
#bring in strings
origin = row[0]
origins.append(origin)
destination = row[1]
destinations.append(destination)
mode = row[2]
modes.append(mode)
#bring in integer
worker = int(row[3])
workers.append(worker)

def draw():
background(155, 155, 155)
m=10
n=10
o=10
p=10
x=0
textSize(18)
stroke(0,0,0)
text ("commuters traveling from", 25, 690)
text ("& traveling to", 380, 690)
text ("by", 25, 725)
#this is the mouse line
line(mouseX, 0, mouseX, 575)
stroke(255,255,255)
#this is the context map
global img
# Draw the image to the screen at coordinate (0,0)
image(img,420,20,210,200)

for origin in origins:
index=0
left1=n
right1=n+10
if left1 < mouseX and mouseX < right1:
fill (0, 0, 255)
text(origin,260,690)
n+=10

for destination in destinations:
index=0
left1=o
right1=o+10
if left1 < mouseX and mouseX < right1:
fill (0, 0, 255)
text(destination,507,690)
o+=10

for mode in modes:
index=0
left1=p
right1=p+10
if left1 < mouseX and mouseX < right1:
fill (0, 0, 255)
text(mode,55,725)
p+=10
for worker in workers:
leftEdge=m
rightEdge=m+10

if leftEdge < mouseX and mouseX < rightEdge:

fill(255,255,255)
stroke(0, 0, 255)
rect(m, 575, 10, -worker*.0015)
textSize(50)
text(worker, 25, 650)
else:
stroke(0)
fill(255,255,255)
rect(m, 575, 10, -worker*.0015)

m+=10

--

--