Assignment 3: Coordinates and Geometries
This is the third assignment of the semester for HES 505. The last few lectures have focused on coordinates and geometries. In this assignment, we’ll use the different functions for accessing and transforming the crs of different spatial objects. We’ll also use a little of the tidyverse to subset the data and access some of the geometry information for one of the observations in our dataset. You’ll need to use both the lectures and the recorded examples (or check out the tidyverse tutorials linked in the lectures). This homework is meant to help reinforce those concepts and identify any gaps that I need to fill in as we go. Make sure to check out the example too!. By the end of this assignment you should be able to:
Use
read.***
andread_***
to bring data into your R environment and determine the data type usingclass
andstr
.Demonstrate the use of pseudocode to outline the steps in a function or analysis.
Access and manipulate the CRS for vector and raster data.
Access and manipulate subsets of the data using standard and tidyverse approaches.
Examine how
R
stores vertices in the geometries ofsf
objects.
You’ll need to accept the link to access the questions.
Instructions
After you’ve joined the assignment repository, you should have this file (named Readme.md) inside of a R project named assignment-3-xx where xx is your github username (or initials).
Once you’ve verified that you’ve correctly cloned the assignment repository, create a new Quarto document. Name this file assignment-3-xxx.qmd and give it a title (like M Williamson Assignment 3). Make sure that you select the html output option (Quarto can do a lot of cool things, but the html format is the least-likely to cause you additional headaches). We’ll be using Quarto throughout the course so it’s worth checking out the other tutorials in the getting started section.
Copy the questions below into your document and change the color of their text.
Save the changes and make your first commit!
Answer the questions making sure save and commit at least 3 more times (having 4 commits is part of the assignment).
Render the document to html (you should now have at least 3 files in the repository: Readme.md, assignment-3-xx.qmd, and assignment-3-xx.html). Commit these changes and push them to the repository on GitHub. You should see the files there when you go to github.com.
The Data
For this assignment, you’ll be looking at 3 different datasets. One from the Center for Disease Control’s PLACES data describing the distribution of chronic health risks, one from the EPA describing exposure to PM2.5 (an important air pollutant), and one describing wildfire risk. You might imagine that as we become increasingly concerned with the environmental justice concerns associated with fire, we might be concerned about whether more smoke increases the risk of chronic respiratory diseases. We won’t totally answer that question this week, but you’ll start to develop the workflow necessary to move towards that type of analysis. All of the data are on the server in the opt/data/data/assignment03/
folder.
The Assignment
- Write out the pseudocode that you would use to set up an analysis of the spatial correlations between chronic asthma risk, exposure to PM2.5, and wildfire. You don’t have to write functions or any actual code. Just write the steps and insert named code blocks for each step.
- Read in the
cdc_nw.shp
,pm_nw.shp
, andwildfire_hazard_agg.tif
files and print the coordinate reference system for each object. Do they match? - Re-project the
cdc_nw.shp
andpm_nw.shp
shapefiles so that they have the same CRS as thewildfire_hazard_agg.tif
file. Verify that all the files have the same projection. - How does reprojecting change the coordinates of the bounding box for the two shapefiles? Show your code
- What class of geometry does the
pm_nw.shp
have (show your code)? Now filter thepm_nw.shp
file so that only the records from Ada County, Idaho are showing. Find the record with the lowest value for PM25. How many coordinates are associated with that geometry?
Solutions are here