$30
CSCI 141
Lab 8: Putting it all together
Introduction
In this lab, you’ll write a program to read historical earthquake data from a file and plot each
earthquake on a map using turtle graphics. An example output is shown in Figure 1.
Figure 1: The output from my solution code.
1 Setup
Create a lab8 directory in your lab environment of choice. Download the following files from
the course webpage and place them in your lab8 folder:
• plot earthquakes.py - this file contains skeleton code and pseudocode
• earthquakes.csv - this file contains the data you’ll be reading
• earth.png - this will be set as the background image in the turtle graphics canvas (this
is done for you by the turtle setup function given in the skeleton code).
1
2 Approach and Guidelines
Implement the parse row function and the remainder of the main function according to the
pseudocode included in comments. Follow the same coding style conventions we’ve been using
up to this point: comment at the top, good variable naming, and so on.
You’ll find that you need many of the structures and concepts we’ve covered in this course to
complete this task—ask your TA if you encounter any problems, and use this opportunity to
take note of any topics you need to brush up on before the final exam.
Some hints:
• The code to read the csv file will look pretty similar to the code I provided in A5 to read
the cancer data files.
• The first line of the file contains column headers, so you’ll need to skip over it before
starting to read data.
• Plotting earthquakes on the map is quite simple: the map image (and turtle canvas) is
720x360 pixels, with (0,0) in the center. Longitude (the x axis) goes from -180 to 180 and
latitude (y axis) goes from -90 to 90, so (0,0) is in the center. To get the canvas (x, y)
coordinates based on a given (lon, lat) coordinate, simply multiply each coordinate by 2.
• The skeleton includes an implementation of the teleport function from Lab 5.
• You can use a turtle object’s circle method to draw a circle. See the documentation for
details on how it is called.
• Coloring the circles is optional. In my color scheme, the red channel is proportional to
magnitude, while the green and blue channels are inversely proportional to magnitude.
For an extra challenge, try coloring the circles based on the date instead of the magnitude.
Submission
Take a screenshot of your program’s output and save it as earthquakes.png. Zip your screenshot and completed plot earthquakes.py file in a file called lab8.zip and submit to Canvas.
2
Rubric
You submitted a single zip file called lab8.zip, containing the correct files 2
The top of your program has comments including your name, date, and a short
description of the program’s purpose.
3
The program reads the earthquake data into a list of dictionaries 15
A circle is drawn for each earthquake 5
The circle’s size varies with the earthquake’s magnitude 5
Total 30 points
3