Joseph Holler's Open Source GIScience Resources at Middlebury College
: In this lesson, we will study and execute R code for the analysis.
Your starting point for this lab analysis will be the code developed over the spring and summer of 2020. In the spring, we solved the problem using spatial SQL queries in PostGIS for the vector analysis, and then we completed the raster analysis using graphic modeler to run GDAL tools in QGIS. Over the summer, Kufre Udoh worked on translating all of the SQL queries and QGIS graphic models into R. At the time, we still did not have the final 20% of data from FEWSnet, and thus also could not truly assess our results with expectations of success.
As you execute the R code, thoroughly compare the code to your analysis plan, and work on integrating the two such that by the end of lab, the analysis plan is identical to the code. Use your best judgement to decide whether to revise the code or to revise your plan.
.md
text document.Fork
the RP-Malcomb
repository. (Wait to do this until Wednesday LAB time!)Clone
the repository to your computer.report.md
document in the repository.Commit
and push
this change.release
of the repository online, titled RP-Malcomb-Preanalysis-Plan
and note in the description that this preanalysis was formulated without accessing any data for the study.Please download the FEWSnet Livelihood zone profile here (for Middlebury students only) and save and extract the data into the data\raw\private
folder.
Let’s set the 2004 Traditional Authorities Resilience Score piece of the study aside for our purposes, and focus on the complete analysis for 2010.
This version of the R script is contained in the procedure\code\RP-Malcomb-jh.Rmd
markdown file. It is divided into chunks so that you can focus on understanding what happens in each chunk, one at a time.
As you learn, please:
str(data_name)
outputs the structure / metadata of a data frame where data_name
should be the name of the data frameplot(st_geometry(data_name))
where data_name
is the name of the SF vector data frameplot(data_name)
where data_name
is the name of the Stars raster data framewrite_sf()
as shown in the final block of code in the R markdown for lab with three parameters: data name, output file ending in .gpkg
for geopackage, and output layer name. For example, write_sf(dhsclusters_2010, here("data","scratch","scratch_output.gpkg"), "scratch1")
would write the DHS cluster points to a geopackage in the scatch
folder, with the layer name scratch1
Now, it’s time to investigate the data sources for the Malcomb et al (2014) study!
I suggest you divide up the task of investigating and describing the data sources and, based on what you find, revising the preanalysis plan. One way to slice it would be to use Table 2 to divide the task by:
commit
and push
the changes, and create a second release
titled RP-Malcomb-Preanalysis-Plan-Data
and note in the description that this preanalysis plan was amended after investigating all data sources for the study, but prior to starting any analysis.Now that you have seen one draft of the code and you have access to all of the data, please revise your workflow plan. You are most welcome to do this in collaboration with the same group: just share the same common markdown
file with one another when you’re finished.
What does []
mean? See here