Preface
This project started as a weekly handout for a graduate course in spatial analysis at Western Washington University. This grew, as course notes sometimes do, into something closer to a short book. That process wasn’t really intentional, I’d fix a confusing explanation, add a section that answers a question, expand a toy example and so on. After two colleagues started using these as the text in their classes I felt I had something worth sharing more broadly.
I am Andy Bunn. I am a professor of environmental sciences at Western Washington University in Bellingham, which sits in the northwest corner of the contiguous United States in a part of the world that is unreasonably beautiful. My research is mostly about paleoclimate and carbon cycling using tree rings. I have been writing R code since about 2000, including dplR, a package for dendrochronology that is part of the openDendro project. I am not a statistician. I am an environmental scientist and teacher who has spent a career working with spatial data.
My own entry into this material came from two graduate courses at Duke University in the late 1990s, one in spatial analysis and one in landscape ecology, both taught by Dean Urban. Urban, who became a lifelong friend and mentor, had a way of making space feel like the most interesting thing in the data. He taught me that space was not a problem to correct for, but a signal worth understanding. That philosophy runs through this book. Dean has since published two books that are much broader in scope than what you’ll find here: Agents and Implications of Landscape Pattern (Urban 2023) and Landscape Ecology: A Task-Oriented Perspective (Urban 2024). Both are worth knowing about if you want to go deeper into landscape ecology as a discipline.
The students these notes were written for are masters students in environmental sciences at WWU. Most of them do applied work. They came to graduate school to better understand ecosystems, watersheds, climate, toxicology, or some other chunk of the world. They’ve taken an introductory stats class covering linear modeling but ususally not math beyond calculus. And many of them are going to spend their careers working with data that have coordinates attached, which means they need to know about spatial analysis.
The emphasis is on building intuition and getting things done in R, not on mathematical derivation. The scope is deliberately narrow: we work with point observations and continuous raster surfaces, not areal data or network structures. We often simulate known patterns before applying methods to real data, because the best way to trust a tool is to watch it find something you planted. We use the Meuse River dataset, a classic, and a few others that connect to ecology and problems relevant to different kinds of environmental science.
If you are an ecologist or environmental scientist who needs to handle spatial structure in your data and want a practical, R-based entry point, this is for you. There is no shortage of spatial analysis textbooks, but most of them are either deeply rooted in GIS workflows, pitched at geographers rather than ecologists, or written at a mathematical level that assumes more background than most field scientists have. This book tries to occupy the middle ground: rigorous enough to be clear about what the methods are doing, accessible enough that a first-year masters student can follow along and run the code.
A few things this book is not. It is not a comprehensive treatment of spatial statistics. It is not a GIS manual. It says almost nothing about areal data (polygons, watersheds, administrative units) – a whole separate analytic world. And it is not a substitute for reading the other literature, which is why each chapter ends with a Further Reading section.
This is a living document. If you find errors, have suggestions, or want to tell me that a particular explanation finally made something click, I’d love to hear from you.
The book is free to read online and openly licensed. The prose and figures are released under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license, and the code under the MIT License. You are welcome to share it, teach from it, and adapt it for noncommercial use, as long as you keep it open and give credit.
Andy Bunn
Bellingham, Washington