Spatial Data Science Basics — Absolute vs. Relative Location
By: Greg Carlton
Tags: Location, Spatial Analysis, Data Science, GIS, Spatial Thinking

Spatial Data Science Basics — Absolute vs. Relative Location

Photo by Tobias on Unsplash.

Every minute of every day, your connected devices are being mined for your locational data.

Where you eat, where you sleep, and even where you party after work is logged by outside entities 24-hours a day, 7-days a week. Corporations use your locational data to create a surprising diversity of products and applications.

Have you ever wondered how Google Maps can have traffic reports for huge swaths of the world? Or, have you found it curious that your favorite delivery app always seems to suggest nearby restaurants to you even without your direct input? In Google’s case, they are aggregating hundreds of thousands of records to estimate vehicle speeds on roadways across the planet. In the case of applications such as DoorDash or UberEats, your individual locational data is being used to encourage you to make a purchase from their service.

While all of this may sound somewhat unnerving and scary, for an aspiring data scientist, there is a silver lining to be had — companies need analysts who can work with locational data. Adding locational aptitude to your resume can help you grow in your career and prosper professionally. In this article, I will introduce the concept of location and detail its use in data science. This core concept might seem simple, but it is more nuanced than you may expect.

An Introduction to Spatial Data Science

Spatial data science is a burgeoning field that combines key aspects of “conventional” aspatial data analysis, such as querying, ETL, data mining, and visualization, with the science of location. A synonym for this, “science of location” is Geography.

Geography has many important tenents and concepts, but there are three key concepts you should know if you want to gain a fuller picture of this discipline: space, place, and location.

Location is the primary subject matter of this article, but I would like to briefly introduce space and place since all three are interconnected.

Space is an abstract concept that is used to describe the relational distance between people, landscape objects, and locations. Space can be mathematically absolute. The physical distance between myself and my neighbor can be measured in precise units, assuming that we each stay anchored to a single location. A surveyor can also precisely measure the bounds of a parcel of real estate in anticipation of a contract offer. In both of these cases, space (linear, rectangular, or otherwise) can be absolutely quantified using measurable units. In many cases, however, space is relative and not easily measured. All of us have personal spaces or bubbles that vary based on our situation. During COVID-19, most of our personal bubbles expanded as we tried to social distance ourselves from strangers, but this personal space may have instead decreased if you were sheltering at home with loved ones. These kinds of variable spaces cannot be quantifiably measured. Many spaces also exist in our minds and imaginations. The space where you met your life partner may have deep meanings to you; Likewise, the space where you used to play with your childhood friends may be deeply sentimental to you. When a space has emotional value, this is known as a place.

Now, you may be reading this and wondering what these concepts have to do with data. After all, in a demanding business world where companies want actualizable insights, what good are abstract concepts like space and place?

Stick with me. I promise you that knowing these concepts is going to come in handy!

Location: The Key Component of Spatial Data

The key component that makes spatial/geographic data unique from aspatial data is location. Open up your relational database or Microsoft Excel spreadsheet and take a quick look at some of your data tables. Do any of your tables have a street address as an attribute or column? What about GPS coordinates? Even a state/province name would work. If your tables have any column that has a locational component, then congratulations are in order, you are working with spatial data!

A location is simply a place on the earth’s surface that is represented by some form of a coordinate system. These coordinates can be absolute, or they can be relative.

Absolute location is generally what most data scientists are used to working with. As its name suggests, absolute location is precise and measurable. GPS coordinates, though prone to small degrees of error, are generally quite precise. Street addresses are the same way: if you put a street address into your favorite mapping application, it will almost always route you to within a few feet of where you want to go.

Relative location, on the other hand, is prone to inaccuracy. This type of location is approximate but not exact. When you ask a stranger for directions, this is generally the type of location you will receive. If someone tells you, “the bank is a couple of streets down, just past the train station,” this is not a precise set of directions, but it will get you close to where you need to go. The location of the bank is relational to other locations such as the train station. It is not uncommon to have datasets where a note/comment field is used to denote location. If a field technician does not have a GPS unit, then they may resort to using handwritten comments to denote a location that they have serviced. These locations are likely to be relative to other landmarks and locations.

Understanding the differences between relative location and absolute location will help you to improve your data analysis and visualization workflows, and help to increase your overall productivity.

Scenario 1: Working with Spatial Data that has an Absolute Location

As a spatial data scientist, the majority of your work is going to see you working with data that has an absolute location affixed to it. The precision of your locational data is going to deeply impact the types of analyses that you can conduct on it. In this case, precision refers to the exactness of your locational data. If you have the exact geographic coordinates of a location, then you can do far more with this data than you can with a city or state name.

Consider the following scenario. You are a data scientist working for a private security company. Your company offers a commercial alarm service for business owners that is usually quite reliable, but for some reason, it has had an unusual number of false alarm incidents over the past month in the fictional city of Springfield, New Mexico. Your team leader wants you to investigate this issue to try to find any patterns that may help to explain what is going on with your alarm product.

When you are given the above table view to work with, can you spot the locational data?

What sets geospatial data analysts apart is that they know how to leverage the science of location to provide valuable insights to their employers.

In this scenario, an analyst who is not used to working with geospatial data may be tempted to focus on the “date” or “incident_type” attributes. While these attributes are important, their importance is diminished without location information. There are three locational attributes in our table view. All three locations can be classified as ‘absolute locations’, but their precision varies.

The “state” column is the least precise of our locational data.

The “city” column is more precise. Using this attribute, it becomes possible to make descriptive comparisons between cities. We can also make some simple visualizations to aid in these comparisons. Naturally, one of the best figures to use in this scenario is the bar chart (as seen in the below figure).

Using the city attribute, it is clear that there are equal numbers of false alarm incidents in Springfield and its suburb, “Suburb City” in June. This is a unique locational insight. We can now rule out the possibility that there is a faulty utility problem in the region since each city uses its own electric grid. Bringing in the temporal component, we may be able to glean even more insights.

While the insights we gained from using the city attribute were helpful, this is hardly our most precise locational data. The “street address” column is even more precise. With this attribute, we can now pinpoint the alarm incidents down to the building level. We can also map each incident as a point on a map through a process known as geocoding.

Geocoding is when you use addresses, names, or coordinates to code the location of a data point to a location on the Earth’s surface. Geocoding can only be conducted using absolute locations and specialized software such as ESRI’s ArcGIS or Tableau Desktop. Geocoding can also be done using Python, as demonstrated by Abdishakur in Towards Data Science.

If we geocode our street addresses, we can create a map that will allow us to visualize our alarm incidents based on where they occurred. This will allow us to determine if there are any spatial or spatio-temporal patterns that can help to explain the incidents that have been occurring. The following map (figure 2) details the location and time of each incident in our hypothetical region.

Map of False Alarm Incidents in the Fictional City of Springfield, NM (Actual Map Depicts Phoenix, AZ) © OpenStreetMap contributors

Using our most precise locational data, we can now see that there are clear spatial clusters of false alarm incidents by date. This tells us that there is likely something going on in the space around these false alarm incidents that are causing them to occur. Without having precise street addresses, it would have been impossible to determine this.

Armed with this information, we can search for events near these locations to try to figure out what happened. In this case, we find out that there are roving blackouts in these locations due to overnight road resurfacing. Since your alarm requires a persistent electricity source, a faulty alarm trigger went off when the alarms were temporarily disconnected by the roadwork.

The lesson in this scenario is that absolute locations are very valuable in data analysis work. The more precise these locations are, the better!

Working with Spatial Data that has a Relative Location

As a data analyst, it is far more uncommon to work with data that has a relative location affixed to it. 90% of the time, location information in databases is absolute and can be geocoded to the landscape. This, however, is not always the case.

Let’s break this concept down with another scenario.

This time, the security company that you work for wants a map of bike thefts at a university campus in our fictional city of Springfield, NM. You are given vague locational information to work with, which was entered by a security officer on the campus.

Looking at the table view, it becomes clear that there are no absolute locations that you can work with here. A lack of absolute locational data means that you can no longer geocode points on a map.

Using the “Officer_Comments” attribute, you realize that you do have the relative location of where these theft incidents occurred. These locations are relative because they are only depicted in relation to other locations on the university campus. Since you know the locations of these related buildings, you can make some inferences about the locations of the theft incidents.

That’s right, the key to working with relative locations is using contextual clues to make inferences. If a comment says “250 ft. from the Rec Center” and you know that there is a bicycle rack in that approximate location, you can infer that the theft happened at the bike rack. Likewise, if a location is stated as being on the “NW Side” of a building, you can use your best judgment to place a point at this location. Geographic Information Systems (GIS) are particularly helpful for adding data points (point features) to a map both through geocoding and by inferential placement.

There are two main issues that you will encounter when you work with relative locations. First, when you “infer” the location of a data point using contextual clues, there are bound to be some data accuracy issues. Let your employer know about these issues in advance. If there are two bicycle racks located within 250 ft. of a building, you may infer that a theft happened at one rack when it actually happened at the other. This creates an accuracy problem, and it may become problematic if you plan on applying geostatistical analysis techniques to your data. The second problem is that inferring locations for large datasets may be burdensome, if not outright impossible.

Conclusion

Being able to work with locational data is becoming an increasingly important skill for data analysts and scientists. Understanding the basics of location can help to increase your analytical capabilities and improve your job performance.