This is a workshop put together by Angela Li of the Center for Spatial Data Science (CSDS) at UChicago for State of the Map 2018.
By the end of this workshop, workshop attendees should be able to:
- Install useful R packages
- Download OSM data from the OpenStreetMap API, using the
osmdata
R package - Map downloaded OSM data in R
- Understand the two formats in which R stores spatial data
Open RStudio and paste the following code into your console, then press Enter to run it:
# Download packages from CRAN
install.packages(c("devtools", "knitr", "magrittr", "sf", "sp", "rmarkdown", "usethis", "osmdata"))
Download this entire lesson (all code, notebooks, and data) to your computer desktop by running the following code in your RStudio console. Respond yes
to all prompts:
usethis::use_course("https://github.com/angela-li/sotmus-r/archive/master.zip")
Once you've downloaded this lesson, open the .Rproj
file to get started.
Use the sotmus-r-complete.Rmd
notebook as a guide to fill out the sotmus-r.Rmd
lesson notebook.
code
: Raw R code generated from notebooksdata
: Intermediate R data objects (to be used in case of bad Internet connection)notebooks
: R Markdown notebooks with R code, produced during workshop. Includes empty notebook (sotmus-r.html
) and filled-out notebook (sotmus-r-complete.html
).slides
: Intro slides (there are only 2 because I worked live in thesotmus-r.Rmd
notebook)
If you're running into issues with RTools (mostly Windows users), check out this solution on Github.
Typing ? before your R command in the console will bring up function documentation in R.
Feel free to email me at ali6@uchicago.edu or reach out on Twitter for questions! Or submit a Github Issue on this page for problems.
osmdata
package website, Githubsf
package website, Github- overpass turbo website: try out sample Overpass API queries
- Overpass API Documentation: examples for learning more about structuring API queries to OpenStreetMap
- Geocomputation in R: free online book about analyzing, visualizing, and modeling spatial data in R
- R for Data Science: free online book about doing data science in R
Thanks to Mark Padgham and rOpenSci for maintaining the osmdata package!
Thanks to Jared Lander, Chris Prener, Jenny Bryan, Software Carpentry, and RStudio Education for informing the design of this workshop repository. In the same vein, please feel free to use this workshop as a template for your own R workshop. (If you do, give me a hoot!)
Note: For exporting xaringan slides to a PDF, I used the webshot
package, instructions for which are found in the xaringan wiki.