3_Earthquake Magnitude Grid

Eric Pietraszkiewicz
Data Mining the City
1 min readSep 27, 2017

Each cell represents one minute — the 60 columns, the 60 minutes in an hour and the 24 rows, the 24 hours in a day. All earthquakes are recorded in the cell corresponding to the minute they occurred, magnitude is represented by the color of the cell (darker being more intense). (note, if there was more than on earthquake in any given minute, the first earthquake to occur is recorded in the cell that represents that minute)

import csvfile_path = "insert file path here"data = []with open(file_path, 'rU') as f:
spamreader = csv.reader(f, dialect='excel', delimiter=',', quotechar='"')
header = spamreader.next()
for row in spamreader:
data.append(row)
grid = [[1]*60 for n in range(24)]
for cell in data:
grid[int(cell[0])][int(cell[1])]= float(cell[5])
w = 20def setup():
size(w*60,w*24)
# fill(0)
stroke(0)
def draw():
x,y = 0,0
for row in grid:
for n in row:
if n == 1:
fill (255,255,255)
else:
fill (255,255-(n*20),255-(n*42.5))
rect (x,y,w,w)
x = x + w
y = y + w
x = 0

--

--