Distance Calculation Modes
Geocodio's distance API lets you calculate driving distance/driving time and straightline/as-the-crow-flies distance (Haversine)
Geocodio's Distance API supports two calculation modes: straightline and driving.
Straightline distance
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:
You need quick proximity filtering (e.g., "find all locations within 50 miles")
Approximate distance is sufficient for your use case
You're processing high volumes where speed matters most
Cost is a concern, as straightline distance costs fewer credits than driving distance
Limitation: Straightline distance underestimates actual travel distance. Driving distances are typically 20-40% longer due to road networks.
Driving distance
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:
You need approximate travel time estimates (ETAs)
Mileage accuracy matters (expense tracking, billing, compliance)
You're making decisions based on real-world travel (dispatch, territory planning)
Note: Geocodio's driving time reflects typical/average travel conditions, not real-time traffic.
Comparison
| Straightline | Driving | |
|---|---|---|
| Speed | Fastest | Moderate |
| Returns travel time | No | Yes |
| Accuracy | Approximate | Road-accurate |
| Credits per calculation | 1 | 2 |
Specifying the mode
Set the mode parameter to either straightline (default) or driving in your API request.