Map matching
Available on the following API tiers:
Snap a sequence of GPS coordinates to the road network and get back a route with turn-by-turn directions. To get road attributes along the matched path instead, use trace attributes.
POSThttps://transit.land/api/v2/routing/valhalla/trace_route
Match a sequence of coordinates to the road network and return the matched route with turn-by-turn directions.
Request
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.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.
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.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.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.
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.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
no_shape is not valid for isochrone.Examplepolyline6
Examplewalk_or_snap
Exampleauto
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06. Required for types 1, 2, 3.YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.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.
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.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.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.
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.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
[[lon,lat],…] or a GeoJSON FeatureCollection. Roads intersecting these rings will be avoided during path finding. Takes one of the 2 forms listed below.properties.levels array to restrict exclusion to specific building/indoor levels in pedestrian routing.geotiff is isochrone-only.Examplejson
"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 -X POST "https://transit.land/api/v2/routing/valhalla/trace_route" \
-H "apikey: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"costing":"auto","shape":[{"lat":37.7891,"lon":-122.4011},{"lat":37.7887,"lon":-122.4016},{"lat":37.7883,"lon":-122.4022},{"lat":37.7879,"lon":-122.4028}],"shape_match":"map_snap"}'Response
Exampleen-US
status.ExampleFound route between points
Example response
Show response
{
"trip": {
"language": "en-US",
"legs": [
{
"maneuvers": [
{
"bearing_after": 224,
"begin_shape_index": 0,
"cost": 8.08,
"end_shape_index": 3,
"instruction": "Drive southwest on Stevenson Street.",
"length": 0.057,
"street_names": [
"Stevenson Street"
],
"time": 6.904,
"travel_mode": "drive",
"travel_type": "car",
"type": 1,
"verbal_multi_cue": true,
"verbal_post_transition_instruction": "Continue for 60 meters.",
"verbal_pre_transition_instruction": "Drive southwest on Stevenson Street. Then You will arrive at your destination.",
"verbal_succinct_transition_instruction": "Drive southwest. Then You will arrive at your destination."
},
{
"bearing_before": 225,
"begin_shape_index": 3,
"cost": 0,
"end_shape_index": 3,
"instruction": "You have arrived at your destination.",
"length": 0,
"time": 0,
"travel_mode": "drive",
"travel_type": "car",
"type": 4,
"verbal_pre_transition_instruction": "You have arrived at your destination.",
"verbal_transition_alert_instruction": "You will arrive at your destination."
}
],
"shape": "shmagAtbwmhFnA`BbAxAjQnV",
"summary": {
"cost": 8.08,
"has_ferry": false,
"has_highway": false,
"has_time_restrictions": false,
"has_toll": false,
"length": 0.057,
"max_lat": 37.788826,
"max_lon": -122.400826,
"min_lat": 37.788458,
"min_lon": -122.401297,
"time": 6.904
}
}
],
"locations": [
{
"lat": 37.7891,
"lon": -122.4011,
"original_index": 0,
"type": "break"
},
{
"lat": 37.7887,
"lon": -122.4016,
"original_index": 1,
"type": "via"
}
],
"status": 0,
"status_message": "Found route between points",
"summary": {
"cost": 8.08,
"has_ferry": false,
"has_highway": false,
"has_time_restrictions": false,
"has_toll": false,
"length": 0.057,
"max_lat": 37.788826,
"max_lon": -122.400826,
"min_lat": 37.788458,
"min_lon": -122.401297,
"time": 6.904
},
"units": "kilometers"
}
}See the Routing Platform overview for API access, travel modes, and the machine-readable schema.
Reference: Valhalla map matching API reference