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, and show regional statistics for utility usage. It's also a huge part of GIS, where many problems are solved with spatial analysis.
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.
Today, spatial analysis is used in epidemiology, biology, statistics, economics, commerce and business, urban planning, geology, oil and gas, and in many other industries.
There are open source tools you can use to perform spatial analysis on a Mapbox map.
You can add Turf to your webpage in the
<head> of your document alongside Mapbox GL JS or Mapbox.js. You can use the CDN (the URL displayed below), or you can download the Turf library and source it locally.
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.