What’s So Special About Spatial Data?
Published: 2020-11-19 21:53:00

*How is Lyft able to tell you how far away your driver is? How does DoorDash give accurate estimates for the food you just ordered? Both of these satisfying user experiences are possible because of spatial data. In this blog, we’ll cover the basics of spatial data and then show some examples of common applications and use cases that use spatial data.*

{% youtube Jhr-whgj65c %}

## What is Spatial Data? 
Spatial Data, often referred to as geospatial data, is any data that contains information about a specific location. In layman’s terms, spatial data is data about location. You may not realize it, but you’re already familiar with spatial data because you interact with it whenever you open your map application to look for the nearest gas station or to see the full landscape of cafes nearby. 

The quantity of data that relates to the location is overwhelming but becomes easier to digest when broken down into the two most commonly used spatial data types.  

## Spatial Data Types
The two primary spatial data types are Geometric and Geographic data. 

- Geographic data is data that can be mapped to a sphere (the sphere in question is usually planet earth).  Geographic data typically refers to longitude and latitude related to the location of an object on earth. GPS data is a good example of geographic data. 
- Geometric data is data that can be mapped to a two-dimensional flat surface. A good example of geometric data would be the floor plan of a building.  

Think about the last time you were running low on gas in an unfamiliar area. You probably used a map application to pull up all the gas stations nearby. That application contains geometric data that captures all the data related to the roads nearby. That application can tell you how long it will take you to get to the gas station by applying driving speed pattern data, with traffic pattern data, and the geometric data. 

The map application is the simplest of spatial data examples. There are literally thousands of other examples. 

## Examples of Spatial Data Applications, Use Cases, and Workloads

### IoT Applications & Spatial Data
The Internet of Things (IoT) refers to networks of objects that are embedded with sensors (think [Bird scooter](https://www.bird.co/) or [Citi Bike](https://www.citibikenyc.com/)) that make it possible to send data from the “thing” to a database. IoT workloads often employ spatial data. Here are a few examples:

- IoT Platform Analytics: Spatial data is the data that shows where users are signing into an application or, to reference the Bird example, accessing a scooter. 
- Real-Time Sensor Detection: This is spatial data on your Fitbit tracking how far you ran (or didn’t run) today. 
- Personalized Views: Google maps knows where you are, and it knows you like Thai food and Mexican food. It can serve you an ad based on your location and the fact that you have a crippling affection for Taco Bell.  

### Transportation/Logistics Applications & Spatial Data
Transportation and logistics companies deal with the movement of people and products. These include companies such as airlines, trucking, railroads, shipping, and logistics firms, as well as companies that provide transportation infrastructure. Here are a few examples of spatial data workloads from that industry:

- Operations Research: Spatial data knows which machine type will work best in a certain location based on the topographical characteristics of a location as well as the surrounding conditions like temperature and traffic. 
- Supply Chain Management: Spatial data can estimate how fast a person or a product will get from point A to point B. 
- Real-Time Analytics: Spatial data can tell you where in the world your latest shipment of olive oil is. 

### Environmental Technology Applications & Spatial Data

Environmental technology is the use of electronic devices to monitor a natural environment. The output of environmental technology could be measurements of tidal patterns, temperature patterns, or the status of a forest fire. The most relatable spatial data workloads have to do with using environmental technology to protect the environment and ourselves. 

- Flood Risk Analysis: Spatial data keeps track of areas that are particularly susceptible to flooding by combining the geographic data with weather data and historical data. 
- Real-Time Natural Disaster Detection: Spatial data can help predict where a wildfire will spread by capturing its current location and then factoring in the wind speed/direction as well as the objects that lay in its path.
- Farming/Irrigation Management: Spatial data can record which areas of a farm have been serviced or not serviced by the machines used for planting, harvesting, pruning, or irrigating. 

These are just a few examples of how spatial data is used in the real-world. There are tons of other [use cases for spatial data](https://carto.com/solutions/) that relate to urban planning, or fraud detection, geomarketing, civil engineering, and more.   

## How to build with Spatial Data

When you talk spatial data you have to talk PostGIS. PostGIS is the spatial database extension for PostgreSQL. It has over 300 different built-ins and functions to make it easier to work with spatial data. PostGIS has helped launch apps like Instagram and FourSquare and is included in the tech stack for countless other applications. 

Until very recently Spatial Data workloads could not reliably be built on any of the truly distributed databases. But that isn’t the case anymore. [CockroachDB](https://www.cockroachlabs.com/blog/spatial-data/), the cloud-native distributed SQL database, now supports spatial data types. Rather than reinvent the wheel, [CockroachDB uses the same PostGIS compatible SQL syntax](https://www.cockroachlabs.com/docs/v20.2/spatial-glossary). So you can build applications that leverage spatial data on a database that’s always on, easy to scale, and simple to use.

Deploying spatial data workloads on a distributed database, rather than a monolithic database means that reads and writes aren’t routed through a single node and you don’t have to do asynchronous replication across multiple sites. And when it’s time to scale to different regions you don’t have to worry about manual scaling responsibilities.  

If you have questions about spatial data you can ask them in the CockroachDB [community slack](https://cockroachdb.slack.com/join/shared_invite/enQtODE2MjY0MDA3OTIxLTQxNWNlOTAzYTlkOTdlZTljMzM4ZTZjMjU5ODcyZjUzYzIyMzIzMjZkY2ZmOWU0OTBkYmNlMjc4YTg5NzE3YTQ). If you want to learn more about deploying distributed spatial data workloads you can look at our [spatial features support documentation](https://www.cockroachlabs.com/docs/v20.2/spatial-features.html).