Spatial Data Analysis in R
Data Science II
Course Information
Course Title: Data Science II
Module: Spatial Data Analysis in R — 5 sessions
Term: August – December 2026
Schedule: 09:10 – 10:50 hrs
Location: Cedetec, Salón 210
Instructor
Bogdan G. Popescu
E-Mail: bgpopescu@tec.mx
Office Hours: By appointment
Module Description
This is the spatial module of Data Science II. Over five sessions it takes you from never having opened a shapefile to producing a complete accessibility analysis and publishing it as a report you can send to someone.
The other modules of this course cover large language models, APIs, web scraping, and SQL. This one covers the thing none of them touch: data that has a location. That is not a niche skill — municipio-level indicators, service coverage, census geography, and crime statistics are all spatial, and treating them as ordinary tables throws away most of what they can tell you.
Everything is done in R, using the sf and terra packages, and written up in Quarto. You have both already; we repurpose them.
Learning Outcomes
Upon completion of this module, students will be able to:
- Explain what a coordinate reference system is and diagnose the errors that follow from getting it wrong.
- Read, inspect, and write spatial data in the common vector formats, and build a spatial layer from an ordinary table of coordinates.
- Join data to geography — by administrative code and by location — and know which to trust when the two disagree.
- Produce a defensible thematic map: choose a rate rather than a count, classify it deliberately, and colour it so the reader is not misled.
- Measure: areas, distances, nearest features, buffers, and overlays.
- Use raster data, and extract a continuous surface into a column of your table.
- Publish the result as a self-contained Quarto document.
What You Need
A laptop with at least 8 GB of RAM, and:
- R 4.4 or later and RStudio — posit.co/download/rstudio-desktop
- Quarto — quarto.org
- The packages installed in Session 1:
install.packages(c("sf", "terra", "tidyterra", "exactextractr",
"ggplot2", "dplyr", "tidyverse", "patchwork",
"classInt", "viridis", "leaflet",
"spData", "cowplot", "ggspatial"))Assessment
This module does not carry its own grade. It feeds the course reto.
Module Content
Session dates are set by the course calendar; see Canvas.
Books and References
- Lovelace, Robin, Jakub Nowosad, and Jannes Muenchow. Geocomputation with R. r.geocompx.org — the standard reference, free online.
- Pebesma, Edzer, and Roger Bivand. Spatial Data Science: With Applications in R. r-spatial.org/book — by the author of
sf. - Gimond, Manuel. Intro to GIS and Spatial Analysis. mgimond.github.io/Spatial — strongest on the conceptual side.
- Hijmans, Robert. Spatial Data Science with R and terra. rspatial.org — by the author of
terra.
Academic Integrity
The use of artificial intelligence is permitted within the university’s ethical guidelines and applicable law, under one condition: every submission includes an appendix stating which AI tools were used, for what purpose, and with which prompts. Undisclosed AI use is academic dishonesty.
Any act of academic dishonesty will result in a failing grade on the work in question, and will be reported to the academic administration.
Attendance
Attendance follows the course policy set by the coordinating instructors. Students with a justified reason for missing a session should email the instructor beforehand.
Students with Special Needs
The university does not discriminate based on disability. Students with approved accommodations must inform their instructors at the beginning of the term. Please see the institutional website for the complete policy.