Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Tiantian's quake exercise #49

Open
wants to merge 1 commit into
base: week04
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions week04/quakes.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
"""A script to find the biggest earthquake in an online dataset."""
import requests
import json

# At the top of the file, import any libraries you will use.
# import ...

# If you want, you can define some functions to help organise your code.
# def helper_function(argument_1, argument_2):
# ...

# When you run the file, it should print out the location and magnitude
# of the biggest earthquake.
# You can run the file with `python quakes.py` from this directory.
if __name__ == "__main__":
# ...do things here to find the results...
quakes = requests.get("http://earthquake.usgs.gov/fdsnws/event/1/query.geojson",
params={
'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"}
)

# The lines below assume that the results are stored in variables
# named max_magnitude and coords, but you can change that.

my_request = json.loads(quakes.text)
largest_quake = quake_feature[0]

for quake in quake_feature:
if quake['properties']['mag'] > largest_quake['properties']['mag']:
largest_quake = quake
max_magnitude = largest_quake['properties']['mag']
coords= largest_quake['geometry']['coordinates'][0],largest_quake['geometry']['coordinates'][1]

print(f"The maximum magnitude is {max_magnitude} "
f"and it occured at coordinates {coords}.")