Abstract

As a long time user and contributor to R, I have also witnessed, like the authors of this book, that R has become an increasingly used programming tool for analysis of various datasets in a wide range of disciplines including those needing spatial analyses. Its flexibility and relatively quick learning curve (despite being a command line tool) allow the quick implementation of computational solutions, supported by a considerable number of libraries (add-on packages). This makes it a very good choice of programming environment either for someone wanting to analyse some data, to test some new methods or to provide useful analytical tools for others (i.e. authoring and building a package to submit to R).
In An Introduction to R for Spatial Analysis and Mapping, Brunsdon and Comber have achieved the difficult task of accompanying the novice reader through a range of useful methods, tips and examples in the use of R. Perhaps more importantly, through this experience the reader will become a knowledgeable learner in R and geographical analysis, capable of tackling other learning materials without fear and of producing good quality analyses.
The authors both lecture on geographical information systems (GIS) and spatial analysis methods at various levels, so it is no surprise that this book is organised in a way that other lecturers may also find useful. Following the principles of ‘learning by doing’, the book takes the reader through some ‘self-test questions’ designed to enhance understanding. These encourage the reader to use their expanding knowledge or develop their own code to answer the question, though of course answers and explanations are given at the end of the chapters. This aspect of the book works very well.
In my opinion the book is certainly a useful contribution. The myriad of available materials on the Web or in other books on R, and spatial analysis more generally, could be considered too numerous or too difficult for a postgraduate student or a researcher starting from scratch and therefore needing an entry-point of reference. This book fulfils that role admirably.
Chapter 1 (Introduction) outlines R and how it may be used for spatial analysis. Twenty-five packages are listed as used in the book, which is probably enough for an introductory text. For the more dedicated practitioner there are now about 134 packages listed in the Spatial ‘task-view’ (cran.r-project.org/web/views/), 55 in the Spatio-temporal one (some incorporated in both of course, such as splancs) and altogether 6548 packages currently in R. R can also be used as an interface to other programming languages such as C or Java, and has substantial possibilities that are covered in the opening chapter, as well as Chapter 10 (Epilogue). I would recommend also going to http://cran.r-project.org/manuals.html where the general introduction to the programme is regularly updated. This website also includes introductions made by persons from various disciplines to which readers may more easily relate, especially for readers with no extensive knowledge in GIS. It is claimed that no particular knowledge is needed to use the book effectively, but some basic understanding would certainly facilitate a quicker learning experience.
Chapter 2 (Data and plots) brings the reader up to speed. In describing the bare essentials of using R, from manipulating or creating different data types and basic plotting of non-spatial data, the authors equip the reader with the skills to generate spatial data plots. This is where we are also introduced to classes such as S3 and S4 in R, i.e. its object orientated (OO) programming capability, S4 being more rigorous and in line with other OO languages.
Chapter 3 (Handling spatial data in R) gets into greater depth with regard to spatial data. Guidance on plotting maps with points, lines and polygons is more detailed and choropleth maps from attributes of these geometries are explained. The reader can play with OpenStreetMap and Google Maps as backgrounds. This gives the reader enough to publish a map with all the necessary features: context, legend, scale, labels, etc. Even though one can sub-select and add attributes to the spatial data manipulated, the chapter nonetheless supposes that the spatial data has been created elsewhere, something the reader will learn a bit more about in Chapter 5. One could regret that issues of definition of reference systems of the spatial data, along with potential use of re-projections, are left mostly to the self-test questions in this section (Q4). Complications that arise when using a background layer fetched using OpenStreetMap and RgoogleMap are also skirted over. This could have been an alert in one of the very useful ‘information boxes’ as it can be a source of troubles. Further aspects of GIS are nonetheless looked at in Chapter 5, including projections and geographical reference systems.
Chapter 4 (Programming in R) is a rather efficient crash course on R programming. In 28 pages the chapter helps the R initiate to do more than just use pre-constructed commands and functions. With well-chosen examples, some tips and tricks are added to the basics of coding scripts in R. More could have been said on a function() returning a list or any R objects (possibly with the call of invisible(), which was mentioned for a plot() on page 119 to prevent a long output). The section 4.5 (Writing functions for spatial data) effectively demonstrates that, if spatial data objects in R come from more complex classes, R has the resource to manipulate them easily with the use of lapply() and mapply(). These functions also represent a first step into parallel programming, which can be done with packages such as Snow. The interested reader can explore this further at the task-view cran.r-project.org/web/views/HighPerformanceComputing.html.
Chapter 5 (Using R as a GIS) comforts both the new learner and those familiar with ArcGIS or QGIS with respect to the use of classical spatial operations and transformations from within R. In Chapter 3 it was made clear that R is able to utilise traditional GIS data formats such as ESRI shapefiles, and therefore GIS operations and transformations can be performed during data preparation using ArcGIS or QGIS. The other solution, which at some point could be needed as part of a particular script, is to perform them within R. Thanks to packages such as sp and rgeos, this is possible and this chapter runs through the main GIS operations and, by doing them, introduces some GIS concepts and vocabulary. Again, this is something of a crash course in GIS, but enough is explained to understand what is going on.
Chapter 6 (Point pattern analysis using R) gets its teeth into spatial analysis. It is worth noting that the purpose of the authors is to run through traditional methods used in spatial analysis and to expose them as R code and snippets using appropriate R packages and not to give a full course on each topic. They more often cite an R package that itself would refer to the literature rather than quoting this literature. Nonetheless, when pointing to details or particular choices of methods they provide the necessary references. R packages are usually quite well documented, therefore I would also encourage readers to consult the help(foo) to find out more about a given function foo with regard to other parameters, literature, and so on. This chapter contains something of a jump in complexity when introducing Kriging. It may have been simpler to have spoken to the continuity of other interpolation methods by choosing the weights as related to the ‘auto-correlation’ of the values themselves at given distances, and then only introducing the ordinary, simple and universal Kriging distinctions.
Chapter 7 (Spatial attribute analysis with R) focuses on inference for spatial relations in attribute values. The focus of the previous chapter was on understanding the distribution of occurrences as the prime interest. This one presents a series of methods inheriting more from the statistical approach of testing models of associations. Unlike common statistical modelling, the assumption of independence of the observations is not met and the interest is on testing the spatial dependence. The spatial occurrences are often aggregated and the data is available as summaries over a set of geographical units covering the whole spatial domain: areal data. The classical global models and indices to test auto-correlation and spatial regression in variables are introduced.
Chapter 8 (Localised spatial analysis) explores, from global to local, the methods of Chapters 6 and 7. As explained in the chapter’s opening, spatial considerations, such as homogeneity, stationary or isotropy, were in the theories of most of the methods presented so far. Consequently, besides a few exploratory mapping and interpolation displays, only global approaches were involved in the analysis. (Note that all chapters have very informative introductions helping the reader to have a critical thinking approach of what they are learning.) Therefore, it is only natural that, if either those considerations are invalid, or if they express the existence of a spatial relation, one would like to map or localise what is detected. Along with clear descriptions of the LISA approach (Local Indicators of Spatial Association) and geographically weighted summary statistics or models, there is also an interesting discussion on the topic of inference and multiple comparisons, which is an important topic in spatial analysis and image analysis.
Chapter 9 (R and Internet data) provides the key to a world of data, quite literally. It teaches the reader to connect to the Internet from within R and accessing or constructing datasets from it. This is a very timely section as datasets are increasingly gathered from open data initiatives. Various data formats can be found, and Brunsdon and Comber give some examples covering what can be expected. Thanks to packages such as rgdal, rgeos and sp, lots of vector and raster data formats can also be utilised by R including the ones provided by Web services adopting the Open Geospatial Consortium (OGC) interoperability framework.
The back cover of An Introduction to R for Spatial Analysis and Mapping promises to take the reader from ‘zero to hero’. A questionable claim, but after a careful reading of this book I am convinced that this statement is genuine. As with all good tutorials, re-using the very insightful pieces of code given will enable the reader to produce as interesting analyses and as beautiful plots as the book provides, and therefore acquire the necessary skills and confidence to progress with the study and utilisation of R. Once hero status is attained, this book is likely to remain close by the R practitioner as a useful guide and mentor.
