Homework Assignment 4 Solution




In this assignment, you will be doing exploratory spatial data analysis. You have been given the flight pattern data of n = 5 birds known as Swainson’s Hawks. The data is recorded from March to September 2012. The objective of this assignment is to learn how to make spatial visualizations. For questions 1, 3, and 4, you will need to create appropriate spatial maps that answer the questions. You will be expected to determine what is a ”good-looking” plot on your own, so some of the work you do will be open-ended. Do not hesitate to ask questions on how to use the new packages however. Remember, every package and function mentioned is there for a reason. Keep a look out for hints posted on Piazza as well. Good luck!


Use R to find answers to all of the following questions (that is, don’t do any by hand or by point-and-click).

Save your code in an R script.

  1. Create a spatial map that properly visualizes the location of all five of the hawks. You will need to represent each point with the longitude and latitude variables. Make sure that it is possible to distinguish the points between each hawk. Also make sure you areas with denser concentrations of points by setting the alpha parameters.

  1. In this dataset, there are two hawks who have documented arrival sequences. Create spatial maps that documents these two sequences. You can examine the arrival sequences by subsetting by stage. In this plot, find appropriate ways to use height and speed in your plot. Once again, make sure to draw separate lines by tag. It is recommended that you write the two sequences as separate plots.

Develop a strategy to determine whether each hawk leaves their nest.3.

Report the time period (in days) of which each hawk leaves, if they do. You are encouraged to use non-spatial visuals to justify your answer. Explain how you achieved your results and whether you had a consistent strategy for each hawk. If you believe a hawk did not leave their nest, you do not need to report their time interval. It is recommended that you take a look at how to use the distGeo() function from the geosphere package to calculate distances between sets of points.

  1. Using spatial maps, visualize the departure sequences of the hawks that leave their nests. You are encouraged to use custom variables in your plots. You will have to decide what variables are useful and how to visualize them. Make sure to comment on each hawk’s migration patterns in your report.

Assemble your answers into a report. Please do not include any raw R output. Instead, present your results as neatly formatted 1 tables or graphics, and write something about each one. You must cite your sources. Your report should be no more than 5 pages including graphics, but excluding code and citations.

What To Submit

Email a digital copy to spring18stat141a@gmail.com. The digital copy must contain your report (as a PDF) and your code (as one or more R scripts).

  • See the graphics checklist on Canvas.


Additionally, submit a printed copy to the box in the statistics department office2 . The printed copy must contain your report and your code (in an appendix). Please print double-sided to save trees. It is your responsibility to make sure the graphics are legible in the printed copy!

Data Documentation

The hawk dataset contains the following features:

event The identification number of the row.

time The timestamp of the event. The time is measured up to hours, no minutes and seconds are recorded.

long The longitude of a hawk at the specific time period.

lat The latitude of a hawk at the specific time period. speed The speed of a hawk at the specific time period. (mi/hr) height The height of a hawk (f t) at the specific time period. stage The life stage that the corresponding hawk is in.

tag The identification number of the hawk. There are five different tags in this dataset.

Relevant Functions

All of the functions from previous assignments, as well as:

ggmap(), get_map(), distGeo()

Relevant Packages

lubridate, ggmap, ggplot2,geosphere,gridExtra

  • 4th floor of Mathematical Sciences Building


error: Content is protected !!