Median Home Value per sf by neighborhood

Hui Liu
Data Mining the City
2 min readOct 4, 2017
import csv
def setup():
size(1100, 700)

with open("medianhomevalue.csv") as f:
reader = csv.reader(f)
header = reader.next()

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

global neighborhoods
neighborhoods=[]

global img
img=loadImage("Garment.JPG")

for row in reader:
value = float(row[1])
values.append(value)
neighborhood = row[0]
neighborhoods.append(neighborhood)

def draw():
background(0)
scalar=0.25
m=50
n=50
x=0
textSize(25)
text("The median home value ($/sf) is:", 50,60)
text("The neighborhood is",50,100)

for neighborhood in neighborhoods:
index=0
left1=n
right1=n+10
if left1 < mouseX and mouseX < right1:
fill(242, 47, 21)
textSize(25)
text(neighborhood,320,100)
n+=10

for value in values:
left=m
right=m+10
if left < mouseX and mouseX < right:
fill(242, 47, 21)
rect(m, 650, 10, -value*scalar)
textSize(25)
text(value, 500, 60)
if value==max(values):
imageMode(CORNER)
image(img,920,15,170,170)
else:
fill(255,255,255)
rect(m, 650, 10, -value*scalar)

m+=10

I want change my topic to housing value things. Visualized the zillow data. The region name and home value are shown by neighborhood.

Because I know Garment District has the highest home value , I add the code to load the image of this area while identifying the maximum value.

However, my assumption is that I don’t know which neighborhood is with the highest value. So I should have loaded images for all neighborhoods, and while the value is maximum, the matching photo will appear. It is a little difficult for me.

--

--