Spatial analysis includes a variety of techniques and processes used to understand the patterns and relationships of geographic features.
Geospatial analysis is a large family of tasks like calculating area and distance and joining points to polygons that enable people to see patterns or relationships within their data. Spatial analysis is used in many industries: to find the nearest coffee shop, calculate travel time, show regional statistics for utility usage, or to analyze accessibility and equity issues like access to ballot drop boxes.
The map below is a classic example of spatial analysis, created by physician John Snow during the 1854 cholera outbreak in London. Snow plotted cholera cases in the Soho area of London around Broad Street and noticed a cluster around the water pump. This led to improved sanitation facilities and the discovery that cholera infection was water-borne rather than airborne.
Spatial analysis is also a huge part of geographic information systems (GIS), where analysts use geospatial data to analyze and solve problems in logistics, retail, urban planning, epidemiology, geology, and many other fields and industries.
You can use Mapbox tools like the Isochrone API or open source tools like Turf.js to do spatial analysis on Mapbox maps.
Isochrones reflect the total geographic area you can reach from a specific starting point, given an amount of time and a mode of transportation.
The Mapbox Isochrone API computes what areas are reachable and returns the reachable regions as contours of polygons or lines that you can display on a map.
The demo below uses the Isochrone API to generate color-shaded polygons that illustrate what areas are reachable within a 15, 30, 45, and 60-minute drive from Newark Liberty International Airport:
Isochrones can be useful for geofencing, the practice of defining virtual boundaries around geographic areas so you can trigger automated workflows when a user travels into or out of a geofenced zone.
By using isochrones as geofences, you can create workflows to:
- Let passengers know when a rideshare driver is two minutes away
- Pick a curbside pickup order when the customer is 20 minutes away
- Send push notifications to truck drivers when they approach a warehouse
- Direct food couriers to high-demand zones during peak delivery hours
When you add Turf to your site, it exposes a global variable
turf from which you can run any of the turf functions. For example, if you have a GeoJSON LineString feature named
dc and you want to know its length in miles, you can use the length function.
The example below uses Mapbox GL JS and Turf to measure the distance along a line using turf.length. Click on the map to start drawing a line.
Click points on a map to create lines that measure distanced using
The Mapbox Java SDK includes a library for using Turf algorithms in Java projects. Here's an example that uses the Java SDK's Turf library with the Maps SDK for Android to generate a circle with a radius expressed in physical distance units:
Get started with the Java SDK's Turf library.