Assignment 4

Author

Your Name

Published

March 25, 2024

Instructions

Please submit your assignment as html file to me via email. Please call your assignment: “yourname_assignment4.html”. For example, I would submit submit something called “popescu_assignment4.html”. Please make sure that it is all in lower case. Please answer all the questions below.

Notice that some questions have more points than others. The maximum points on this assignment is 39.

1 Question

Total points: 2

Download the provided dataset containing air quality measurements from various monitoring stations in major cities in the US. Load it in R using the `read.csv’ function. The original data is from the US Environmental Protection Agency.

Calculate the number of PM2.5 stations per state. Your map should be as close as possible to what you see below. To get full points you need to

  • Aggregate correctly the stations for the Pollutant Standard, “PM25 24-hour 2012” and for the Parameter Name “PM2.5 - Local Conditions” (1 point)
  • Use a viridis scheme (1 point)

Your output should look like below:

2 Question

Total points: 2

Calculate the average PM2.5 level per state.

  • Calculate correctly the mean (1 point)
  • Use a viridis scheme (1 point)

Your output should looke like below.

3 Question

Total points: 4

Download the provided dataset showing railroads in the US (1840-1870). Also download the US shape file. Create the following animation.

Hint: To get to animate lines, you need to use geom_path option. Thus, the entire option in ggplot should look like this: geom_path(rail_merge, mapping = aes(x = X, y = Y, group = L1_year))

The dataframe that you will plot should look like below:

head(rail_merge, n=11)

4 Question

Total points: 5

From 1992 to 2013, China underwent significant internal development across various sectors, resulting in transformative changes in its economy, society, and infrastructure. China continued its economic reforms initiated under Deng Xiaoping in the late 1970s. The country saw extensive industrialization, urbanization, and infrastructure development. Understanding which regions developed internally is important.

For this exercise, we will use satellite luminosity to understand Chinese internal development. You can download the world luminosity data in 1992 and the world luminosity data in 2013.

Now map luminosity in China in 1992.

To get full points you need to:

  • Load the China shapefile from relevant sources (1 point)
  • Calculate correctly the zonal statistic for 1992 (3 points)
  • Map luminosity adequately (1 point)

5 Question

Total points: 5

Now map luminosity in China in 2013.

To get full points you need to

  • Load the China shapefile from relevant sources (1 point)
  • Calculate correctly the zonal statistic for 1992 (3 points)
  • Map luminosity adequately (1 point)

6 Question

Total points: 1

Now calculate the mean zonal statistic at the CHN_2 level. Produce the following visualization.

7 Question

Total points: 3

Now produce the following graph showing the difference between 2013 and 1992.

  • use the viridis theme to represent change (1 point)
  • edit the legend title appropriately (1 point)

Now produce the followoing boxplot, showing the difference (1 point)

8 Question

Total points: 2

What are the top 3 regions (NAME_1) that grew the most in China. What about the bottom 3?

9 Bonus Question

Total points: 10

Write a function that calculates all the luminosity data from 1992 to 2013 for China. You can download the entire data for the whole world (1992-2013) (8.16GB).

Your function should:

  • use operations with strings that automatically detecly the names and the location of the file
  • unzip the archives automatically
  • unzip further the relevant tiff files
  • create zonal statistic for every year for China
  • merge back those stistics to the China shapefile.

10 Question

Total points: 4

Produce a time trend for the top 3 regions (NAME_1) that grew the most in China and the top 3 that grew the least (from 1992 to 2013). If you were not able to produce the function, you can download the processed luminosity data.

To get full points you need:

  • correctly select the top 3 regions that grew (1 point)
  • correctly select the bottom 3 regions that did not grow (1 point)
  • produce the time trend (1 point)
  • correctly manipulate the dataframe to produce a long format (1 point)