Visualizing Earthquakes

Celeste Layne
Data Mining the City
2 min readSep 28, 2017

--

Using USGS data, I visualize the magnitude and location of earthquakes that have occurred over the past day. Disclaimer: This data includes ‘quarry blasts’ and ‘explosions’ that can be easily filtered out.

All Earthquakes form the past day | 09.27.2017
import csv

def setup():
size(600, 600)

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

# print header

global magnitudes
magnitudes = []

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

# print magnitudes
def draw():
background(44, 62, 80)
scalar = 100
barWidth = 5
x = 0

textSize(14)
text("The earthquake magnitude is ", 50, 350)

for place, magnitude in zip(places, magnitudes):

leftEdge = x - (barWidth)/2
rightEdge = x + (barWidth)/2

if leftEdge < mouseX and mouseX < rightEdge:
fill(236,100,75)
text(str(magnitude), 260, 350)
text(str(place), 300, 350)
# fill(236,100,75)
rect(x, height/2, barWidth, (magnitude*scalar)*(-1))
else:
fill(197, 239, 247)
rect(x, height/2, 5, (magnitude*scalar)*(-1))
x += 10

Finally got the SlippyMapper library to work; but I think the projection is off (it dropped me in Paramus, NJ) so I have some more internal rubber-ducking to do.

--

--

Celeste Layne
Data Mining the City

Software Engineer. Trinidad-born. Queens-grown. NYC forever.