Congesting Pricing (take 2)

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

For the midterm presentation I wanted to move a step beyond this bar graph data demonstration, and do a map. I combined and cleaned several data sources in GIS and then converted the polygons to points with geolocated Long / Lats which I thought function better. Unfortunately, I couldn’t figure out how to add a variable in a way that this could run without the text overlapping on this map which proved to be a lot more complicated than it was on the bar graph (where I had the same problem initially but was able to troubleshoot it and make it work). A few sleepless nights, and this is what I have.

Method

import spatialpixel.mapping.slippymapper as slippymapper
import csv
def setup():
size(1100, 1000, P2D)
fill(0,0,0)

global NYC
NYC = slippymapper.SlippyMapper(40.634494, -73.957588, 12, 'carto-dark', 1100, 1000)

#open VLP .csv
with open('VLPData.csv') as f:
reader = csv.reader(f)
header = reader.next ()
#define list items
global vlpPovertyLevels
vlpPovertyLevels = []
global vlpDrives
vlpDrives = []
global vlpntanames
vlpntanames = []

for row in reader:
#bring in strings
vlpPovertyLevel = row[7]
vlpPovertyLevels.append(vlpPovertyLevel)
vlpDrive = row[9]
vlpDrives.append(vlpDrive)
vlpntaname = row[2]
vlpntanames.append(vlpntaname)

#define lat long
vlplatitude = float(row[0])
vlplongitude = float(row[1])
#create marker
def vlpmarker(vlplatitude, vlplongitude, marker1):
marker1.noStroke()
marker1.fill(0, 180, 255, 95)
marker1.ellipse(vlplatitude, vlplongitude, 15, 15)
#add marker interactivity
if dist(mouseX,mouseY,vlplatitude,vlplongitude)<=10:
marker1.fill(0, 180, 255)
marker1.ellipse(vlplatitude,vlplongitude,20,20)
#implement += variable
textSize(18)
fill(255,255,255)
zerovlpname=0
zerovlppov=0
zerovlpdrive=0
if dist(mouseX,mouseY,vlplatitude,vlplongitude)<=10:
for vlpntaname in vlpntanames:
marker1.text(vlpntaname,215,905)
for vlpPovertyLevel in vlpPovertyLevels:
marker1.text(vlpPovertyLevel,375,930)
for vlpDrive in vlpDrives:
marker1.text(vlpDrive,470,955)
NYC.addMarker(vlplatitude,vlplongitude,vlpmarker)

#open A .csv
with open('AData.csv') as f:
reader = csv.reader(f)
header = reader.next ()
#define list items
global aPovertyLevels
aPovertyLevels = []
global aDrives
aDrives = []
global antanames
antanames = []

for row in reader:
#bring in strings
aPovertyLevel = row[7]
aPovertyLevels.append(aPovertyLevel)
aDrive = row[9]
aDrives.append(aDrive)
antaname = row[2]
antanames.append(antaname)

#define lat long
alatitude = float(row[0])
alongitude = float(row[1])
#create marker
def amarker(alatitude, alongitude, marker2):
marker2.noStroke()
marker2.fill(255, 10, 240, 95)
marker2.ellipse(alatitude, alongitude, 15, 15)
if dist(mouseX,mouseY,alatitude,alongitude)<=10:
marker2.fill(255,10,240)
marker2.ellipse(alatitude,alongitude,20,20)
if dist(mouseX,mouseY,alatitude,alongitude)<=10:
index=0
textSize(18)
fill(255,255,255)
for antaname in antanames:
marker2.text(antaname,220,905)
for aPovertyLevel in aPovertyLevels:
marker2.text(aPovertyLevel,375,930)
for aDrive in aDrives:
marker2.text(aDrive,470,955)

NYC.addMarker(alatitude,alongitude,amarker)
#open HP .csv
with open('HPData.csv') as f:
reader = csv.reader(f)
header = reader.next ()

#define list items
global hpPovertyLevels
hpPovertyLevels = []
global hpDrives
hpDrives = []
global hpntanames
hpntanames = []

for row in reader:
#bring in strings
hpPovertyLevel = row[7]
hpPovertyLevels.append(hpPovertyLevel)
hpDrive = row[9]
hpDrives.append(hpDrive)
hpntaname = row[2]
hpntanames.append(hpntaname)
#define lat long
hplatitude = float(row[0])
hplongitude = float(row[1])
#create marker
def hpmarker(hplatitude, hplongitude, marker3):
marker3.noStroke()
marker3.fill(255, 0, 0, 95)
marker3.ellipse(hplatitude, hplongitude, 15, 15)
if dist(mouseX,mouseY,hplatitude,hplongitude)<=10:
marker3.fill(255,0,0)
marker3.ellipse(hplatitude,hplongitude,20,20)
index=0
textSize(18)
fill(255,255,255)
for hpntaname in hpntanames:
marker3.text(hpntaname,220,905)
for hpPovertyLevel in hpPovertyLevels:
marker3.text(hpPovertyLevel,375,930)
for hpDrive in hpDrives:
marker3.text(hpDrive,470,955)

NYC.addMarker(hplatitude,hplongitude,hpmarker)

NYC.render()

def draw():
background(255)
NYC.draw()
#this is the title text
textSize(35)
fill(255,255,255)
text ("In Brooklyn, Who Would Pay for Congestion Pricing?", 25, 50)
textSize(24)
fill(255,255,255)
text("Approximately 402,600 Brooklynites work in Manhattan", 25, 775)
text("Of them, approximately 23,050 (or 6%) drive or ride in personal vehicles", 25, 805)
text("These commuters are very likely to pay tolls under the Congestion Pricing scheme", 25, 835)
text("So who are they?", 25, 865)
textSize(18)
fill(255,255,255)
text("Neighborhood Name:", 25, 905)
text("Concentration of Federal Poverty Level:", 25, 930)
text("Concentration of People who Drive Alone to Work:", 25, 955)

Data Sources:

US Census Bureau, Journey to Work, https://www.census.gov/topics/employment/commuting.html

US Census Bureau, Table B17001, Poverty Status from Last 12 Months by Age and Sex, https://factfinder.census.gov/faces/tableservices/jsf/pages/productview.xhtml?src=bkmk

US Census Bureau, Table B08101, Means of Transportation to Work by Age by Census Tract, https://factfinder.census.gov/faces/tableservices/jsf/pages/productview.xhtml?src=bkmk

NYC Open Data, Census Tract to NTA https://data.cityofnewyork.us/City-Government/2010-Census-Tract-to-Neighborhood-Tabulation-Area-/8ius-dhrr

--

--