Visualizing Earthquake

Suprima Bhele
Data Mining the City
1 min readSep 29, 2017
def setup():
size(3100,1000)
import csv
#file_path = "W:\Fall 2017\DataMining"
with open("/W:/Fall 2017/DataMining/quakes.csv") as f:
reader=csv.reader(f)
header=reader.next()


global magnitudes
magnitudes = []

for row in reader:
magnitude=float(row[4])
magnitudes.append(magnitude)

def draw():
background(0)
magnitude=magnitudes[0]
scalar=45
x=45
fill(255,255,0)
textSize(36)
text("Most recent Earthquakes, 2017",220,100)
for magnitude in magnitudes:
y=(height - (magnitude*scalar))/2
leftEdge = x - (10) / 2
rightEdge = x + (10) / 2
fill(0,0,0)




if leftEdge < mouseX and mouseX < rightEdge and magnitude>=4.0:
fill(255,0,0)
rect(x, y-20, 10, magnitude*scalar)
x += 11
y +=2
textSize(24)
fill(255,0,0)
text("Magnitude is greater than 4.0, 2017",220,800)

elif leftEdge < mouseX and mouseX < rightEdge and magnitude< 4.0:
fill(0,0,255)
rect(x, y-20, 10, magnitude*scalar)
x += 11
y +=2
textSize(24)
fill(0,0,255)
text("Magnitude is less than 4.0, 2017",220,830)
else:
fill(255,255,255)
rect(x, y-20, 10, magnitude*scalar)
x += 11
y +=2

--

--