1 Introduction

This book is about using the power of computers to do things with geographic data.It teaches a range of spatial skills, including: reading, writing and manipulating geographic data; making static and interactive maps; applying geocomputation to solve real-world problems; and modeling geographic phenomena.By demonstrating how various geographic operations can be linked, in reproducible ‘code chunks’ that intersperse the prose, the book also teaches a transparent and thus scientific workflow.Learning how to use the wealth of geospatial tools available from the R command line can be exciting, but creating new ones can be truly liberating.Using the command-line driven approach taught throughout, and programming techniques covered in Chapter 10, can help remove constraints on your creativity imposed by software.After reading the book and completing the exercises, you should therefore feel empowered witha strong understanding of the possibilities opened up by R’s impressive geographic capabilities,new skills to solve real-world problems with geographic data,and the ability to communicate your work with maps and reproducible code.

Over the last few decades free and open source software for geospatial (FOSS4G) has progressed at an astonishing rate.Thanks to organizations such as OSGeo, geographic data analysis is no longer the preserve of those with expensive hardware and software: anyone can now download and run high-performance spatial libraries.Open source Geographic Information Systems (GIS), such as QGIS, have made geographic analysis accessible worldwide.GIS programs tend to emphasize graphical user interfaces (GUIs), with the unintended consequence of discouraging reproducibility (although many can be used from the command line as we’ll see in Chapter 9).R, by contrast, emphasizes the command line interface (CLI).A simplistic comparison between the different approaches is illustrated in Table 1.1.

Table 1.1: Differences in emphasis between software packages (Graphical User Interface (GUI) of Geographic Information Systems (GIS) and R).
AttributeDesktop GIS (GUI)R
Home disciplinesGeographyComputing, Statistics
Software focusGraphical User InterfaceCommand line
ReproducibilityMinimalMaximal

This book is motivated by the importance of reproducibility for scientific research (see the note below).It aims to make reproducible geographic data analysis workflows more accessible, and demonstrate the power of open geospatial software available from the command-line.“Interfaces to other software are part of R” (Eddelbuettel and Balamuta 2018).This means that in addition to outstanding ‘in house’ capabilities, R allows access to many other spatial software libraries, explained in Section 1.2 and demonstrated in Chapter 9.Before going into the details of the software, however, it is worth taking a step back and thinking about what we mean by geocomputation.

Reproducibility is a major advantage of command-line interfaces, but what does it mean in practice?We define it as follows: “A process in which the same results can be generated by others using publicly accessible code.” This may sound simple and easy to achieve (which it is if you carefully maintain your R code in script files), but has profound implications for teaching and the scientific process (Pebesma, Nüst, and Bivand 2012).