Applied Spatial Data Analysis with R

Logo

Web site with book resources (data, scripts)

View the Project on GitHub r-spatial/asdar-book.org

This web site contains scripts and datasets to reproduce all the examples in

Applied Spatial Data Analysis with R. Roger S. Bivand, Edzer Pebesma and V. Gómez-Rubio UseR! Series, Springer. 2nd ed. 2013, xviii+405 pp., Softcover ISBN: 978-1-4614-7617-7

Authors

Roger S. Bivand is Professor of Geography in the Department of Economics at Norwegian School of Economics, Bergen, Norway.

Edzer Pebesma is Professor of Geoinformatics at Westfälische Wilhelms-Universität, Münster, Germany.

Virgilio Gómez-Rubio is Associate Professor in the Department of Mathematics at Universidad de Castilla-La Mancha, Albacete, Spain.

Data sets and scripts

Data set bundles (.zip files for all datasets occuring in a chapter of the book), for chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

Verbatim (unchanged) book scripts, for chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

Updated and simplifed book scripts, for chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

Reproducing the whole book

A script that downloads all scripts is:

# ASDAR_BOOK <- "http://www.asdar-book.org/book2ed"
ASDAR_BOOK <- "http://r-spatial.github.io/asdar-book.org/book2ed"
chapters <- c("hello", "cm", "vis", "die", "cm2",
"std", "sppa", "geos", "lat", "dismap")
for (i in chapters) {
  fn <- paste(i, "mod.R", sep="_")
  download.file(paste(ASDAR_BOOK, fn, sep = "/"), fn)
}

To run all examples of the book, a number of packages need to be installed. Running the following script will install those that are not already present:

pkgs <- c("boot", "CARBayes", "classInt", "coda", "cubature",
"DCluster", "deldir", "epitools", "geoR", "ggplot2", "gstat",
"INLA", "lattice", "latticeExtra", "lmtest", "maps", "maptools",
"MASS", "McSpatial", "mgcv", "nlme", "osmar", "pgirmess", "plm",
"R2BayesX", "R2WinBUGS", "raster", "RColorBrewer", "rgdal", "rgeos",
"sandwich", "sp", "spacetime", "spatstat", "spdep", "spgwr", "sphet",
"splancs", "xts")

for (p in pkgs) {
	if (inherits(try(library(p, character.only = TRUE)), "try-error"))
		install.packages(p, character.only = TRUE)
}

A script that downloads all data and scripts, extracts data, and reproduces the whole book is:

chapters <- c("hello", "cm", "vis", "die", "cm2",
"std", "sppa", "geos", "lat", "dismap")
for (i in chapters) {
  ASDAR_BOOK <- "http://r-spatial.github.io/asdar-book"
  fn <- paste(i, "mod.R", sep="_")
  download.file(paste(ASDAR_BOOK, "book2ed", fn, sep = "/"), fn)
  da <- paste(i, "bundle.zip", sep = "_")
  download.file(paste(ASDAR_BOOK, "bundles2ed", da, sep = "/"), da)
  unzip(da)
  source(fn, echo = TRUE)
}

Errata

First edition

The data and scripts of the first edition of the book,

Applied Spatial Data Analysis with R, Roger S. Bivand, Edzer J. Pebesma and V. Gómez-Rubio. UseR! Series, Springer. 2008, 378 p., Softcover. ISBN: 978-0-387-78170-9

are found here: