101  Spatial Overview

When we talk about spatial and geospatial feature engineering, we want to focus on the transformation and enrichment of the data set, based on spatial information. Typically this will be longitude and latitude-based, with the additional information being based on areas and regions such as cities or countries.

What sets these methods apart from most of the other methods in this book is where the information comes from. If you want to find the closest city to an observation, you need a data set of all the cities and their location. The types of questions you are trying to answer will determine whether you need a reference data set, which could be multiple references depending on the question itself. We can divide up the methods in this section based on whether they need reference data and how they use it.

If you require a reference data set, then we call it map matching as it uses geography as a join key between the data set we are working on and an external data set. Under this category we have any distance to a reference point as covered in Chapter 105, and finding the nearest element as covered in Chapter 106. These are quite similar as they require the same type of information, distance, but they do different things with them. Another thing we could do is count and summarize what falls within a given distance or region, which is covered in Chapter 107. By knowing the location of something we are also able to query certain types of information such as β€œheight from sea”, β€œrainfall in inches in 2000” and so on. We cover these types of methods in Chapter 108. When the reference data is a road or transit network, the relevant distance is travel time rather than a straight line, as covered in Chapter 109. We can think of this as a network expansion of the distance calculations.

If we don’t have a need for a reference data, then we either deal with map synthesis or intrinsic methods. One example of map synthesis is using neighboring observations as information. We cover these methods in Chapter 110. Intrinsic methods use the observation’s own geometry. This could be area, perimeter, or compactness among other methods. We look at how we can incorporate that information in Chapter 113.

Another way to slice this is by the question you are asking, since the same question can be answered against several different kinds of reference data. You can read the following as a lookup list once you know what you are holding.

We are aware that some chapters repeat in the above list. A count of restaurants within 500 metres and a count of road kilometres within 500 metres are the same feature with a different reference geometry, and both live in Chapter 107.

Before we move on to any of these methods, we need to talk about fundamental things related to spatial information. You typically get the values as coordinates, which by themselves likely aren’t useful, and we look at what to do with them in Chapter 103. We will furthermore talk about how to properly use these coordinates. Longitude and latitude are not grid points but notation used to locate points on a sphere. If we are not using the right distance or area calculations we will get the wrong answers. With that we can also discretize them in Chapter 104, and take the basis expansions and learned representations of Chapter 111 and Chapter 112.

If we are working with a reference data set we also need to think about what it comes with and from where. Dealing with data quality, especially from the reference data set is hugely important, and we will cover that in Chapter 102.