Code
birdRichness <- readRDS("data/birdRichnessMexico.rds")These are the course notes and not a textbook. They are more like a field guide written by someone who has gotten lost in these woods before and wants to help you find your way through.
The notes are hands-on by design. You will write code, look at data, make maps, fit models, and interpret results. Each section builds on what came before. The math shows up when it needs to, but the emphasis throughout is on doing spatial analysis and understanding what you’re doing – not on deriving things for their own sake.
I’ll point you to textbooks and papers along the way. Read them. They complement what we’re doing here and will matter when you’re working on your own data and I’m not around to ask.
These notes are a living document. They change based on what works, what doesn’t, and what you ask about in class. If something is wrong or unclear, tell me.
The notes move through the core ideas of spatial analysis in roughly this order:
plot() and summary() behave differently depending on what you give them.Each chapter builds on the last, so working through them in order is recommended.
You are going to learn to see the world spatially. That sounds dramatic, but I mean it practically: by the end of this course you will be able to look at a dataset, ask where things are happening and why, and have real tools to answer those questions. That is not a small thing.
The people who do this work well are not necessarily the ones who find it easiest. They’re the ones who run the code when it breaks, read the error messages, ask questions, and keep going. That’s it. That’s the whole secret.
So: set up your project, download the data, and let’s get to work.
This document was written in Markdown using using quarto and built with R version 4.5.2. You should be reasonably up to date on your versions of R, RStudio, and relevant packages. You can update your packages by running:
Run that now. And anytime it occurs to you. It’s always a good idea to be up to date with your packages.
To follow along with the examples, you’ll want a working RStudio project.
Create a new RStudio project
Go to File → New Project → New Directory → New Project. Give it a name (for example spatial-course) and choose where to save it.
Download the data/ folder
The datasets used in the examples are available in the data/ folder of the course repository. Download that folder and place it inside your project directory.
You can download the data directly from the GitHub repo. Here is hard link to it:
https://github.com/AndyBunn/spatialNotes/releases/download/data-latest/data.zip
Once it’s unzipped your folder structure should look something like this:
spatial-course/
├── data/
│ ├── birdRichnessMexico.rds
│ ├── mtbDEM.tif
│ └── ...
└── spatial-course.Rproj
In your code, use paths like "data/birdRichnessMexico.rds" rather than full file paths. This keeps the code portable and ensures it will run on different machines without modification. E.g.,
When you make a Rmd file for your work, save it in the project’s root directory. For instance if you have the first two assignments saved in files called “MtBakerHomework.Rmd” and “pointPatternHomework.Rmd,” your file and folder structure might look something like this:
spatial-course/
├── data/
│ ├── birdRichnessMexico.rds
│ ├── mtbDEM.tif
│ └── ...
├── MtBakerHomework.Rmd
├── pointPatternHomework.Rmd
└── spatial-course.Rproj