Compute travel times and distances between every source and every target. Useful for ranking candidates by travel time before planning a full route.
GETPOSThttps://transit.land/api/v2/routing/valhalla/sources_to_targets
Calculate a time-distance matrix from multiple source locations to multiple target locations. Useful for solving optimization problems.
Request
The request object, url-encoded. Identical to the POST body. Encode spaces as %20 rather than +, or send the JSON without spaces; a + is not decoded as a space here and the request will be rejected as unparseable.
expansion_max_distance
integerMaximum path distance in meters for an expansion. Currently this is implemented for the timedistancematrix algorithm. Source-target pairs whose cheapest path distance exceeds this limit will be returned as unreachable (with null time and distance). Early-exit after finding this many targets. Only valid for TDMatrix algorithm.
Not all formats are supported by all endpoints, e.g. no_shape is not valid for isochrone.Enumpolyline6polyline5geojsonno_shape
Examplepolyline6
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Preferred approach heading in degrees.
How close in degrees a given street's angle must be in order for it to be considered as in the same direction of the heading parameter. The default value is service configuration dependent (60 by default).
minimum_reachability
integerMinimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively). Label echoed in the response.
node_snap_tolerance
numberSnap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
If set, edges whose layer does not match this value are discarded from candidate search. Note that this is a "soft" filter, meaning if no other candidates are found, Valhalla will fall back to including edges that did not match this filter.
Preferred side of road to snap to.Exampleopposite
Candidate search radius in meters: all viable edge candidates within the radius are correlated. If none are found, the best one outside the radius is correlated. The default is service dependent, and defaults to 0 (only the closest edge is considered as candidate). The max value is service configuration dependent (200 by default).
Rank snap candidates by distance to input. Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
Optional filters to exclude candidate edges based on their attribution.
Street address hint for snapping.
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other
Exampleprimary
street_side_max_distance
integerThe max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street. Beyond this distance the side of street is set to none. The default value is service configuration dependent (1000 by default).
street_side_tolerance
integerIf your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none otherwise your side of street will be left or right depending on direction of travel. The default value is service configuration dependent (5 by default).
First and last location are always forced to break.Enumbreakthroughviabreak_through
Examplebreak
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Preferred approach heading in degrees.
How close in degrees a given street's angle must be in order for it to be considered as in the same direction of the heading parameter. The default value is service configuration dependent (60 by default).
minimum_reachability
integerMinimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively). Label echoed in the response.
node_snap_tolerance
numberSnap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
If set, edges whose layer does not match this value are discarded from candidate search. Note that this is a "soft" filter, meaning if no other candidates are found, Valhalla will fall back to including edges that did not match this filter.
Preferred side of road to snap to.Exampleopposite
Candidate search radius in meters: all viable edge candidates within the radius are correlated. If none are found, the best one outside the radius is correlated. The default is service dependent, and defaults to 0 (only the closest edge is considered as candidate). The max value is service configuration dependent (200 by default).
Rank snap candidates by distance to input. Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
Optional filters to exclude candidate edges based on their attribution.
Street address hint for snapping.
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other
Exampleprimary
street_side_max_distance
integerThe max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street. Beyond this distance the side of street is set to none. The default value is service configuration dependent (1000 by default).
street_side_tolerance
integerIf your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none otherwise your side of street will be left or right depending on direction of travel. The default value is service configuration dependent (5 by default).
First and last location are always forced to break.Enumbreakthroughviabreak_through
Examplebreak
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Preferred approach heading in degrees.
How close in degrees a given street's angle must be in order for it to be considered as in the same direction of the heading parameter. The default value is service configuration dependent (60 by default).
minimum_reachability
integerMinimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively). Label echoed in the response.
node_snap_tolerance
numberSnap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
If set, edges whose layer does not match this value are discarded from candidate search. Note that this is a "soft" filter, meaning if no other candidates are found, Valhalla will fall back to including edges that did not match this filter.
Preferred side of road to snap to.Exampleopposite
Candidate search radius in meters: all viable edge candidates within the radius are correlated. If none are found, the best one outside the radius is correlated. The default is service dependent, and defaults to 0 (only the closest edge is considered as candidate). The max value is service configuration dependent (200 by default).
Rank snap candidates by distance to input. Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
Optional filters to exclude candidate edges based on their attribution.
Street address hint for snapping.
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other
Exampleprimary
street_side_max_distance
integerThe max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street. Beyond this distance the side of street is set to none. The default value is service configuration dependent (1000 by default).
street_side_tolerance
integerIf your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none otherwise your side of street will be left or right depending on direction of travel. The default value is service configuration dependent (5 by default).
First and last location are always forced to break.Enumbreakthroughviabreak_through
Examplebreak
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Preferred approach heading in degrees.
How close in degrees a given street's angle must be in order for it to be considered as in the same direction of the heading parameter. The default value is service configuration dependent (60 by default).
minimum_reachability
integerMinimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively). Label echoed in the response.
node_snap_tolerance
numberSnap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
If set, edges whose layer does not match this value are discarded from candidate search. Note that this is a "soft" filter, meaning if no other candidates are found, Valhalla will fall back to including edges that did not match this filter.
Preferred side of road to snap to.Exampleopposite
Candidate search radius in meters: all viable edge candidates within the radius are correlated. If none are found, the best one outside the radius is correlated. The default is service dependent, and defaults to 0 (only the closest edge is considered as candidate). The max value is service configuration dependent (200 by default).
Rank snap candidates by distance to input. Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
Optional filters to exclude candidate edges based on their attribution.
Street address hint for snapping.
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other
Exampleprimary
street_side_max_distance
integerThe max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street. Beyond this distance the side of street is set to none. The default value is service configuration dependent (1000 by default).
street_side_tolerance
integerIf your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none otherwise your side of street will be left or right depending on direction of travel. The default value is service configuration dependent (5 by default).
First and last location are always forced to break.Enumbreakthroughviabreak_through
Examplebreak
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
Include detailed per-cell metadata in the response. Not available here: multimodal — transit routing is served by the Transitland Routing API at /otp/plan, not by this engine.Enumautobicyclepedestriantruckbustaximotor_scootermotorcyclebikeshareauto_pedestrian
Exampleauto
Costing options keyed by costing model name.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
0=current, 1=depart_at, 2=arrive_by, 3=invariant ISO 8601 local datetime string in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06. Required for types 1, 2, 3.
exclude_locations
array: objectA set of locations to exclude or avoid within a route.
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Preferred approach heading in degrees.
How close in degrees a given street's angle must be in order for it to be considered as in the same direction of the heading parameter. The default value is service configuration dependent (60 by default).
minimum_reachability
integerMinimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively). Label echoed in the response.
node_snap_tolerance
numberSnap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
If set, edges whose layer does not match this value are discarded from candidate search. Note that this is a "soft" filter, meaning if no other candidates are found, Valhalla will fall back to including edges that did not match this filter.
Preferred side of road to snap to.Exampleopposite
Candidate search radius in meters: all viable edge candidates within the radius are correlated. If none are found, the best one outside the radius is correlated. The default is service dependent, and defaults to 0 (only the closest edge is considered as candidate). The max value is service configuration dependent (200 by default).
Rank snap candidates by distance to input. Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
Optional filters to exclude candidate edges based on their attribution.
Street address hint for snapping.
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other
Exampleprimary
street_side_max_distance
integerThe max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street. Beyond this distance the side of street is set to none. The default value is service configuration dependent (1000 by default).
street_side_tolerance
integerIf your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none otherwise your side of street will be left or right depending on direction of travel. The default value is service configuration dependent (5 by default).
First and last location are always forced to break.Enumbreakthroughviabreak_through
Examplebreak
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Latitude of the map location in degrees. If provided the lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
Preferred approach heading in degrees.
How close in degrees a given street's angle must be in order for it to be considered as in the same direction of the heading parameter. The default value is service configuration dependent (60 by default).
minimum_reachability
integerMinimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively). Label echoed in the response.
node_snap_tolerance
numberSnap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
If set, edges whose layer does not match this value are discarded from candidate search. Note that this is a "soft" filter, meaning if no other candidates are found, Valhalla will fall back to including edges that did not match this filter.
Preferred side of road to snap to.Exampleopposite
Candidate search radius in meters: all viable edge candidates within the radius are correlated. If none are found, the best one outside the radius is correlated. The default is service dependent, and defaults to 0 (only the closest edge is considered as candidate). The max value is service configuration dependent (200 by default).
Rank snap candidates by distance to input. Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
Optional filters to exclude candidate edges based on their attribution.
Street address hint for snapping.
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other
Exampleprimary
street_side_max_distance
integerThe max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street. Beyond this distance the side of street is set to none. The default value is service configuration dependent (1000 by default).
street_side_tolerance
integerIf your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none otherwise your side of street will be left or right depending on direction of travel. The default value is service configuration dependent (5 by default).
First and last location are always forced to break.Enumbreakthroughviabreak_through
Examplebreak
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
exclude_polygons
array or objectArray of coordinate rings [[lon,lat],…] or a GeoJSON FeatureCollection. Roads intersecting these rings will be avoided during path finding. Takes one of the 2 forms listed below.
Array of closed coordinate rings. All edges intersecting any ring are excluded.
GeoJSON FeatureCollection. Each Feature may carry a properties.levels array to restrict exclusion to specific building/indoor levels in pedestrian routing.
Not all formats are supported by all endpoints, e.g. geotiff is isochrone-only.Enumjsongpxosrmpbfgeotiffmvt
Examplejson
Arbitrary request identifier echoed in the response.
BCP47 locale for narrative output. See locales/ for supported values. linear_cost_factors
array: objectCustomized cost factors that influence path finding, specified as an array of JSON objects. Objects can be either a GeoJSON linestring feature and a "factor" property or a plain object with a "shape" key, whose value needs to be an encoded polyline (with 6 digit precision), and a "factor" key whose value needs to be float. Valhalla will perform an edge walk (see the map matching documentation for more info) to match the geometry onto edges and use those factors in costing. Edges with factors larger than 1 will be increasingly avoided, while edges with factors smaller than 1 increasingly favored.
Example request
curl --get "https://transit.land/api/v2/routing/valhalla/sources_to_targets" \
-H "apikey: YOUR_API_KEY" \
--data-urlencode 'json={"costing":"auto","sources":[{"lat":37.7793,"lon":-122.4193},{"lat":37.7817,"lon":-122.4108}],"targets":[{"lat":37.7817,"lon":-122.4108},{"lat":37.7844,"lon":-122.4079}]}'
Response
Which matrix algorithm answered the request.Examplecostmatrix
The requested sources, snapped to the network.
Latitude of the snapped location.
Longitude of the snapped location.
Latitude of the snapped location.
Longitude of the snapped location.
sources_to_targets
array or objectThe matrix itself. Its shape follows the request's verbose flag, which defaults to true: verbose gives one row per source holding a cell per target, while verbose: false gives two parallel arrays-of-arrays instead. Takes one of the 2 forms listed below.
Verbose form. One row per source, each holding one cell per target.
Compact form, returned when verbose is false.
The requested targets, snapped to the network.
Latitude of the snapped location.
Longitude of the snapped location.
Latitude of the snapped location.
Longitude of the snapped location.
Units the distances are expressed in. Example response
Show response
{
"algorithm": "costmatrix",
"sources": [
{
"lat": 37.779214,
"lon": -122.419983
},
{
"lat": 37.782246,
"lon": -122.410884
}
],
"sources_to_targets": [
[
{
"begin_heading": 350.9,
"begin_lat": 37.779214,
"begin_lon": -122.419983,
"cost": 247.47,
"distance": 1.053,
"end_heading": 83,
"end_lat": 37.782246,
"end_lon": -122.410884,
"from_index": 0,
"time": 130,
"to_index": 0
},
{
"begin_heading": 350.9,
"begin_lat": 37.779214,
"begin_lon": -122.419983,
"cost": 405.357,
"distance": 1.546,
"end_heading": 134.8,
"end_lat": 37.784135,
"end_lon": -122.408233,
"from_index": 0,
"time": 196,
"to_index": 1
}
],
[
{
"begin_heading": 83,
"begin_lat": 37.782246,
"begin_lon": -122.410884,
"cost": 300,
"distance": 1.221,
"end_heading": 83,
"end_lat": 37.782246,
"end_lon": -122.410884,
"from_index": 1,
"time": 160,
"to_index": 0
},
{
"begin_heading": 83,
"begin_lat": 37.782246,
"begin_lon": -122.410884,
"cost": 177.063,
"distance": 0.495,
"end_heading": 314.8,
"end_lat": 37.784135,
"end_lon": -122.408233,
"from_index": 1,
"time": 70,
"to_index": 1
}
]
],
"targets": [
{
"lat": 37.782246,
"lon": -122.410884
},
{
"lat": 37.784135,
"lon": -122.408233
}
],
"units": "kilometers"
}