Chapter 1 Introduction

1.1 Why use this book ?

Read this book if you would like to be able to make maps from African data using R. It will introduce you to just enough of the required understanding of spatial data and R to be able to make useful maps. These maps that we are talking about, are those that are used to communicate data rather than maps used for navigation. For example you might want to show the numbers of COVID-19 cases in different regions, or the types of buildings or transport routes or land uses. You might want to present such maps in a report, a newspaper article, an interactive web application or a scientific paper.

1.2 Why R ?

R can do nearly anything, is free, open-source and has a great community of people keen to help each other. R is code based so that once you learn, for example, how to write the code to make a map for one month, you can modify that code to make 12 monthly maps. Then you can share that code with a colleague and they can make a small modification to make 12 similarly monthly maps for a different region. As such, R is good for re-useability and reproducibility. The R ecosystem has great mechanisms for sharing code and data, this means that you can benefit from the work of others and also allows you to generate impact by sharing your own work.

[mention QGIS]

1.3 Why African data ?

There are three main reasons that we focus on Africa : rapidly growing open-source communities, a lack of existing targeted resources and great needs in, for example, health and environment. The rapid growth in open-source communities is seen in the birth of R user-groups in many African cities and more generally in the popularity of organisations like code4Africa. Learners within these communities are likely to learn more easily when training resources use examples with which they are more familiar. We are not aware of existing training resources focussing on African examples. Some of the greatest health and environment needs occur on the African continent. Data solutions and papers in the academic literature are still often led from the North. There is a great potential for local analysts to develop solutions to local issues. Making maps can be a useful contribution and the needed R skills can also lead to more efficient general data workflows.

1.4 Who for ?

The book is aimed principally at analysts who want to make maps from African data as a part of their routine work. We expect that readers will have had some limited experience of R and/or spatial data but this is not strictly required. We will take you step-by-step through code to obtain, manipulate and visualise spatial data. We focus on routine tasks and developing confidence and resilience in applying them, rather than moving to more advanced analyses.

1.5 What this book will not cover

For those that are interested in spatial analyses we refer you to the excellent recent book Geocomputation with R. The afrimapr book, in comparison, will cover fewer processes but do so in more detail and assuming less prior knowledge of R and spatial data. We see the two books as being complementary. Those that wish to take their work further after this afrimapr book should find the geocompr book useful. Those that have been through the geocompr book and would like more detail on visualising varied data sources in R should find this afrimapr book useful.

1.6 How the book is organised

Structure of the books guides the reader and subsequent chapter build on the knowledge and skills gained in the preceding ones. The level of difficulty increases as the reader progresses through the book. Therefore, it starts with taster chapter demonstrating the aims and capabilities of the book using very simple code and examples. One exception is the recap chapter, that can be found at the end of the book, which provides a recap of R fundamentals. Furthermore, the key chapters cover different topics related to description, manipulation and visualisation of spatial data.

1.7 Book formatting

Each chapter of the book follows similar, fixed structure. It begins with the presentation of chapter goals, including the list of learning objectives in a green box (hence they can be easily found in each section).

Learning objectives

  • Learning objective 1
  • Learning objective 2
  • Learning objective 3
Moreover, at the end of the subsection there is a purple box with exercises relevant for a given topic.

Exercise 1:

Exercise 2:

Importantly, the solutions to the exercises are showed at the end of the chapter. The book also features yellow boxes that contain useful tips and shortcuts. At the end of each chapter there is also a small section with additional resources and links related to the topic.