The U.S. Geological Survey (USGS) has raw data available online. More info at the USGS earthquakes page.
This notebook was started by Physics teacher and Quarknet member Peter Apps, York Middle/High School, Retsof, NY.
In [1]:
#importing what we'll need
import numpy as np
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
In the box below, uncomment one of the data sets by deleting the # at the beginning of the line. Here's the full listing of the different data sets you can grab.
In [2]:
# Just earthquakes from the past hour
#data = pd.read_csv("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.csv")
# All earthquake events in the last month
data = pd.read_csv("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv")
# Only large earthquakes (magnitude 4.5 or greater) in teh past month
#data = pd.read_csv("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.csv")
In [3]:
data.head(4)
Out[3]:
In [4]:
# Set variables for scatter plot
x = data.longitude
y = data.latitude
plt.scatter(x,y)
plt.title('Earthquakes around the world (last month)')
plt.xlabel('Longitude')
plt.ylabel('Latitude')
# This actually shows the plot
plt.show()
In [ ]: