Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Background: In this project we continue to study earthquake activity. We will use a file with data once again obtained from the United States Geological

Background:

In this project we continue to study earthquake activity. We will use a file with data once again obtained from the United States Geological Survey website, about earthquakes of magnitude 5 or greater that have occurred across the planet over the past year (since November 1, 2017).

In this project we continue to study earthquake activity. We will use a file with data once again obtained from the United States Geological Survey website, about earthquakes of magnitude 5 or greater that have occurred across the planet over the past year (since November 1, 2017).

Requirements:

Functions to read and process earthquake data saved in a file are adapted from Ch. 7 of the text.

Function readFile is based on the function in ch. 7 of the text (p. 255). You will need to revise it to accommodate the earthquake data file analyzed in this project: the earthquake file we are using has a header line, each line has a return ( ) character, the values are comma (not space) separated, and the longitude and latitude are in different fields (columns) than the data in the text.

(readFile will be very similar to equake_readf from Project 7-2, except that it will return a dictionary rather than a list.)

Functions euclidD, createCentroids, and createClusters are all copied from Ch. 7 of the text. You will need to add docstrings and helpful in-line comments.

Note that the createClusters function includes code to report the results of the cluster analysis (for c in clusters ). This is helpful for testing createClusters with a small data dictionary (data file), but you may comment this out for the large earthquake file.

visualizeQuakes is based on the function in Ch. 7 of the text. visualizeQuakes in this project has k (the number of clusters) and r (the number of times to repeat cluster analysis) as parameters, along with the dataFile parameter. As in the text, visualizeQuakes should call readFile, createCentroids, and createClusters.

visualizeQuakes will also call a new function, eqDraw, to plot the earthquake data on a world map. visualizeQuakes should return None. You will need to write a docstring and add comments to visualizeQuakes.

eqDraw is a new function that will be called by visualizeQuakes to do the work of plotting the results of the k-means analysis on a world map. eqDraw will have three parameters: k, eqDict, the earthquake data dictionary, and eqClusters, the list of clusters generated for the earthquake data by the k-means cluster analysis

eqDraw will comprise the drawing code that is included in visualizeQuakes in the text. You should change the screensize method arguments to 1800 and 900, to reflect the size of the world map .gif that we will use. You can also use the anonymous turtle from the turtle module (i.e., you do not need to define quakeT). Tip: include speed('fastest')*.

Finally, define a main function to assign values to k, r, and f, and call visualizeQuakes. main should return None. Include code in your .py file to call the main function.

given file "earthquakes.txt":

time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type,horizontalError,depthError,magError,magNst,status,locationSource,magSource 2018-02-27T20:11:04.000Z,-6.2147,142.8358,10,5.2,mb,,24,5.328,0.8,us,us2000d8u9,2018-02-27T20:53:09.719Z,"90km W of Mendi, Papua New Guinea",earthquake,4.2,1.7,0.051,130,reviewed,us,us 2018-02-27T17:29:23.350Z,-60.1778,150.7321,10,5.9,mwb,,43,7.222,1.4,us,us2000d8rl,2018-02-27T19:31:51.991Z,"West of Macquarie Island",earthquake,8.2,1.8,0.053,34,reviewed,us,us 2018-02-27T16:19:53.880Z,-6.0855,142.8469,10,5.2,mb,,33,5.397,0.85,us,us2000d8r4,2018-02-27T17:50:36.040Z,"78km SSW of Porgera, Papua New Guinea",earthquake,8.4,1.8,0.045,162,reviewed,us,us 2018-02-27T14:11:18.610Z,-6.3589,142.9858,14.45,5,mb,,56,5.123,0.74,us,us2000d8q9,2018-02-27T17:54:04.040Z,"76km WSW of Mendi, Papua New Guinea",earthquake,9.2,4.4,0.082,47,reviewed,us,us 2018-02-27T13:58:27.080Z,-6.3793,143.203,14.7,5,mww,,28,4.939,0.67,us,us2000d8q3,2018-02-27T16:07:21.727Z,"54km WSW of Mendi, Papua New Guinea",earthquake,5.7,3.7,0.075,17,reviewed,us,us 2018-02-27T07:19:23.350Z,-6.3225,142.7909,10,5.2,mb,,51,5.301,0.89,us,us2000d8nf,2018-02-27T07:37:19.040Z,"96km W of Mendi, Papua New Guinea",earthquake,7.3,1.6,0.06,93,reviewed,us,us 2018-02-27T06:19:12.240Z,-6.4178,143.0483,10,5.6,mww,,34,5.038,1.29,us,us2000d8my,2018-02-27T17:25:19.040Z,"71km WSW of Mendi, Papua New Guinea",earthquake,7.6,1.9,0.061,26,reviewed,us,us 2018-02-27T05:17:58.320Z,-18.8524,169.2939,196.49,5.5,mww,,102,2.721,0.91,us,us2000d8mh,2018-02-27T21:05:42.040Z,"77km N of Isangel, Vanuatu",earthquake,8.4,4.5,0.073,18,reviewed,us,us 2018-02-27T02:15:07.930Z,-6.5309,143.2716,10,5.2,mb,,84,4.793,1.02,us,us2000d8k4,2018-02-27T05:36:51.666Z,"57km SW of Mendi, Papua New Guinea",earthquake,8.6,1.9,0.095,36,reviewed,us,us 2018-02-27T00:55:22.590Z,-6.0456,142.6355,10,5,mb,,29,5.588,1,us,us2000d8jk,2018-02-27T08:58:00.339Z,"89km SW of Porgera, Papua New Guinea",earthquake,7.6,1.9,0.064,77,reviewed,us,us 2018-02-27T00:08:13.280Z,-6.4713,143.3485,10,5.1,mb,,26,4.769,1.48,us,us2000d8j8,2018-02-27T00:30:37.040Z,"46km SW of Mendi, Papua New Guinea",earthquake,7.2,1.7,0.058,96,reviewed,us,us 2018-02-26T21:52:36.940Z,-6.3587,142.8545,10,5,mb,,30,5.229,0.92,us,us2000d8gk,2018-02-26T22:31:13.040Z,"90km WSW of Mendi, Papua New Guinea",earthquake,5.8,1.8,0.071,63,reviewed,us,us 2018-02-26T19:21:51.820Z,-6.4892,143.4601,22.52,5.1,mb,,26,4.67,1.34,us,us2000d8dl,2018-02-27T15:19:52.040Z,"40km SSW of Mendi, Papua New Guinea",earthquake,8,4.2,0.05,130,reviewed,us,us 2018-02-26T18:28:03.530Z,-6.036,142.7017,20,5.4,mww,,19,5.542,1,us,us2000d8bx,2018-02-27T15:33:06.352Z,"83km SW of Porgera, Papua New Guinea",earthquake,5.1,1.8,0.069,20,reviewed,us,us 2018-02-26T17:41:15.710Z,-5.7791,142.5541,10,5.2,mb,,28,5.815,0.82,us,us2000d8au,2018-02-27T16:39:27.040Z,"79km WSW of Porgera, Papua New Guinea",earthquake,8,1.8,0.055,110,reviewed,us,us 2018-02-26T15:17:59.470Z,-6.495,143.255,13.81,6.2,mww,,19,4.828,0.9,us,us2000d867,2018-02-26T23:39:06.019Z,"56km SW of Mendi, Papua New Guinea",earthquake,4.1,3.1,0.048,41,reviewed,us,us 2018-02-26T13:34:53.480Z,-2.7732,126.6953,8.42,6.1,mww,,38,3.584,0.77,us,us2000d855,2018-02-26T20:45:42.143Z,"45km NE of Airbuaya, Indonesia",earthquake,6.8,2.8,0.048,41,reviewed,us,us 2018-02-26T12:34:54.350Z,-6.3147,143.3448,26.7,5.2,mb,,38,4.869,0.94,us,us2000d84y,2018-02-26T13:20:33.040Z,"37km WSW of Mendi, Papua New Guinea",earthquake,9.5,4.1,0.055,108,reviewed,us,us 2018-02-26T12:29:30.730Z,-6.297,143.2469,40.01,5,mb,,30,4.955,0.99,us,us2000d84e,2018-02-26T12:46:57.040Z,"46km WSW of Mendi, Papua New Guinea",earthquake,7.9,8.4,0.081,49,reviewed,us,us 2018-02-26T11:56:07.450Z,-6.5004,143.5538,13.33,5.7,mww,,20,4.591,0.91,us,us2000d83z,2018-02-26T20:27:14.040Z,"37km SSW of Mendi, Papua New Guinea",earthquake,5,4.1,0.073,18,reviewed,us,us 2018-02-26T09:19:43.850Z,-6.3315,142.8392,60.3,5,mb,,48,5.257,1.16,us,us2000d81l,2018-02-26T09:39:31.040Z,"91km W of Mendi, Papua New Guinea",earthquake,8.4,7.8,0.068,69,reviewed,us,us 2018-02-26T08:26:59.340Z,-6.4274,143.2706,23.64,6,mww,,39,4.856,1.01,us,us2000d80x,2018-02-26T20:34:56.040Z,"50km WSW of Mendi, Papua New Guinea",earthquake,7.4,4.8,0.073,18,reviewed,us,us 2018-02-26T07:01:49.200Z,-6.1196,142.6353,35,5.1,mb,,50,5.545,1.51,us,us2000d7zv,2018-02-26T07:23:13.040Z,"95km SW of Porgera, Papua New Guinea",earthquake,8.4,2,0.055,108,reviewed,us,us 2018-02-26T05:28:01.740Z,-6.2495,142.7798,10.81,5,mb,,54,5.353,1.31,us,us2000d7ym,2018-02-26T06:02:56.854Z,"96km W of Mendi, Papua New Guinea",earthquake,6.9,4.2,0.069,67,reviewed,us,us 2018-02-26T04:41:02.340Z,-5.4195,151.8309,35,5.6,mww,,60,1.264,1.1,us,us2000d7y3,2018-02-26T14:30:26.040Z,"127km SSW of Kokopo, Papua New Guinea",earthquake,6.2,2,0.071,19,reviewed,us,us

given world map:

image text in transcribed

code given:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

using python, thank you!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

=+5. What are the advantages of an online rsum? [LO-4]

Answered: 1 week ago

Question

LO3.2 Describe demand and explain how it can change.

Answered: 1 week ago