MPHY0021: Research Software Engineering With Python


Classroom exercise: the biggest earthquake in the UK this century

The Problem

GeoJSON is a JSON-based file format for sharing geographic data. One example dataset is the USGS earthquake data:

In [1]:
import requests
quakes = requests.get("http://earthquake.usgs.gov/fdsnws/event/1/query.geojson",
                          'starttime': "2000-01-01",
                          "maxlatitude": "58.723",
                          "minlatitude": "50.008",
                          "maxlongitude": "1.67",
                          "minlongitude": "-9.756",
                          "minmagnitude": "1",
                          "endtime": "2018-10-11",
                          "orderby": "time-asc"}
In [2]:

Your exercise: determine the location of the largest magnitude earthquake in the UK this century.

You'll need to:

  • Get the text of the web result
  • Parse the data as JSON
  • Understand how the data is structured into dictionaries and lists
    • Where is the magnitude?
    • Where is the place description or coordinates?
  • Program a search through all the quakes to find the biggest quake
  • Find the place of the biggest quake
  • Form a URL for an online map service at that latitude and longitude: look back at the introductory example
  • Display that image