Geocodio's Distance API supports two calculation modes: straightline and driving.
Straightline distance (also called "as the crow flies") calculates the direct geometric path between two points on Earth's surface using the Haversine equation. This mode is fast and doesn't consider roads or terrain.
Straightline distance is useful when:
Limitation: Straightline distance underestimates actual travel distance. Driving distances are typically 20-40% longer due to road networks.
Geocodio's Distance API can also calculate driving distance and time based on the actual route a vehicle would travel on roads. This mode also returns estimated driving time in seconds.
Driving distance and driving time is useful when:
Note: Geocodio's driving time reflects typical/average travel conditions, not real-time traffic.
| Straightline | Driving | |
|---|---|---|
| Speed | Fastest | Moderate |
| Returns travel time | No | Yes |
| Accuracy | Approximate | Road-accurate |
| Credits per calculation | 1 | 2 |
Set the mode parameter to either straightline (default) or driving in your API request.