Preface
This project started as a weekly handout for a graduate course in spatial analysis at Western Washington University. Over time this grew 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 some 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 wet, but quite 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 usually 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 narrow on purpose. We work with point observations and continuous raster surfaces, not areal data or network structures. We often simulate known patterns before applying methods to field 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 environmental scientist or ecologist 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 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 run the code and follow along.
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) which is 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.
The book is free to read online and openly licensed. The text 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.
If you’d like to cite the book, it has a DOI: 10.5281/zenodo.20651828. That link always points to the latest version. A citation looks like:
Bunn, A. G. (2026). Spatial Analysis for Environmental Data: An R-Based Introduction. https://doi.org/10.5281/zenodo.20651828
Andy Bunn
Bellingham, Washington