Skip to content
Documentation

Locate

Available on the following API tiers:

Transitland v2Beta

Report what the road network looks like near one or more coordinates: which edges a location would snap to, how far away they are, and what the graph knows about them. Useful for debugging routes.

GETPOSThttps://transit.land/api/v2/routing/valhalla/locate

Find the nearest road or path network locations for given coordinates. Useful for debugging why a route behaves the way it does.

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.

locations
array: object
Required
date_time
string
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
display_lat
number
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.
display_lon
number
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.
heading
integer
Preferred approach heading in degrees.
heading_tolerance
integer
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).
lat
number
Required
lon
number
Required
minimum_reachability
integer
Minimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively).
Default50
name
string
Label echoed in the response.
node_snap_tolerance
number
Snap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
preferred_layer
integer
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
string
Preferred side of road to snap to.
Defaulteither
Enumsameoppositeeither

Exampleopposite

radius
integer
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_candidates
boolean
Rank snap candidates by distance to input.
Defaulttrue
search_cutoff
integer
Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
search_filter
object
Optional filters to exclude candidate edges based on their attribution.
street
string
Street address hint for snapping.
street_side_cutoff
string
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other

Exampleprimary

street_side_max_distance
integer
The 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
integer
If 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).
type
string
First and last location are always forced to break.
Defaultbreak
Enumbreakthroughviabreak_through

Examplebreak

waiting
number
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
date_time
string
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
display_lat
number
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.
display_lon
number
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.
heading
integer
Preferred approach heading in degrees.
heading_tolerance
integer
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).
lat
number
Required
lon
number
Required
minimum_reachability
integer
Minimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively).
Default50
name
string
Label echoed in the response.
node_snap_tolerance
number
Snap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
preferred_layer
integer
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
string
Preferred side of road to snap to.
Defaulteither
Enumsameoppositeeither

Exampleopposite

radius
integer
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_candidates
boolean
Rank snap candidates by distance to input.
Defaulttrue
search_cutoff
integer
Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
search_filter
object
Optional filters to exclude candidate edges based on their attribution.
street
string
Street address hint for snapping.
street_side_cutoff
string
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other

Exampleprimary

street_side_max_distance
integer
The 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
integer
If 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).
type
string
First and last location are always forced to break.
Defaultbreak
Enumbreakthroughviabreak_through

Examplebreak

waiting
number
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
verbose
boolean
Return dense edge and node attribution. When false, only the closest point, way ID, and side of street are returned.
Defaultfalse
costing
string
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
object
Costing options keyed by costing model name.
auto
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
bicycle
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
bikeshare
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
bus
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
motor_scooter
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
motorcycle
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
pedestrian
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
taxi
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
truck
object
Options shared by all costing models. Parsed in src/sif/dynamiccost.cc.
date_time
object
type
integer
0=current, 1=depart_at, 2=arrive_by, 3=invariant
Enum0123
value
string
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: object
A set of locations to exclude or avoid within a route.
date_time
string
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
display_lat
number
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.
display_lon
number
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.
heading
integer
Preferred approach heading in degrees.
heading_tolerance
integer
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).
lat
number
Required
lon
number
Required
minimum_reachability
integer
Minimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively).
Default50
name
string
Label echoed in the response.
node_snap_tolerance
number
Snap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
preferred_layer
integer
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
string
Preferred side of road to snap to.
Defaulteither
Enumsameoppositeeither

Exampleopposite

radius
integer
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_candidates
boolean
Rank snap candidates by distance to input.
Defaulttrue
search_cutoff
integer
Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
search_filter
object
Optional filters to exclude candidate edges based on their attribution.
street
string
Street address hint for snapping.
street_side_cutoff
string
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other

Exampleprimary

street_side_max_distance
integer
The 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
integer
If 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).
type
string
First and last location are always forced to break.
Defaultbreak
Enumbreakthroughviabreak_through

Examplebreak

waiting
number
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
date_time
string
Per-location ISO 8601 datetime override, in the format YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.
display_lat
number
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.
display_lon
number
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.
heading
integer
Preferred approach heading in degrees.
heading_tolerance
integer
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).
lat
number
Required
lon
number
Required
minimum_reachability
integer
Minimum number of reachable edges for a snap candidate. The default and max values are service configuration dependent (50 and 100 by default, respectively).
Default50
name
string
Label echoed in the response.
node_snap_tolerance
number
Snap-to-node distance tolerance in meters. The default value is service dependent (5 by default).
preferred_layer
integer
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
string
Preferred side of road to snap to.
Defaulteither
Enumsameoppositeeither

Exampleopposite

radius
integer
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_candidates
boolean
Rank snap candidates by distance to input.
Defaulttrue
search_cutoff
integer
Hard cutoff for candidate search in meters. Default is service configuration dependent (35000 by default).
search_filter
object
Optional filters to exclude candidate edges based on their attribution.
street
string
Street address hint for snapping.
street_side_cutoff
string
Enummotorwaytrunkprimarysecondarytertiaryunclassifiedresidentialservice_other

Exampleprimary

street_side_max_distance
integer
The 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
integer
If 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).
type
string
First and last location are always forced to break.
Defaultbreak
Enumbreakthroughviabreak_through

Examplebreak

waiting
number
Waiting time in seconds at this stop (break/break_through only, not origin/destination).
exclude_polygons
array or object
Array 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.
option 1
array: array
Array of closed coordinate rings. All edges intersecting any ring are excluded.
option 2
object
GeoJSON FeatureCollection. Each Feature may carry a properties.levels array to restrict exclusion to specific building/indoor levels in pedestrian routing.
format
string
Not all formats are supported by all endpoints, e.g. geotiff is isochrone-only.
Defaultjson
Enumjsongpxosrmpbfgeotiffmvt

Examplejson

id
string
Arbitrary request identifier echoed in the response.
language
string
BCP47 locale for narrative output. See locales/ for supported values.
Defaulten-US
linear_cost_factors
array: object
Customized 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.
option 1
object
option 2
object
option 1
object
option 2
object
units
string
Defaultkm
Enumkmmilesmi

Example request

curl --get "https://transit.land/api/v2/routing/valhalla/locate" \
  -H "apikey: YOUR_API_KEY" \
  --data-urlencode 'json={"costing":"auto","locations":[{"lat":37.7793,"lon":-122.4193}],"verbose":true}'

Response

edges
array: object
Candidate edges the location could snap to, nearest first.
access_restrictions
array: object
Restrictions that apply to travel on the edge.
bounding_circle
object
Circle bounding the search that found this edge.
correlated_lat
number
Latitude of the point on the edge the location snapped to.
correlated_lon
number
Longitude of the point on the edge the location snapped to.
distance
number
Distance in meters from the requested point to the snapped point.
edge
object
Graph attributes of the edge.
edge_id
object
Graph identifier of the edge, split into its tile components.
edge_info
object
Names, shape, and OSM way identifiers for the edge.
heading
number
Compass bearing of the edge at the snapped point, in degrees.
inbound_reach
integer
How much of the network can reach this edge, used to detect disconnected islands.
linear_reference
string
OpenLR linear reference for the edge.
live_speed
object
Live traffic speed on the edge, when traffic data is loaded.
outbound_reach
integer
How much of the network this edge can reach.
percent_along
number
How far along the edge the snapped point falls, from 0 to 1.
predicted_speeds
array: number
Historical speed profile for the edge, when one is available.
shoulder
boolean
Whether the edge has a shoulder.
side_of_street
string
Which side of the edge the requested point lies on.
Enumleftrightneither
access_restrictions
array: object
Restrictions that apply to travel on the edge.
bounding_circle
object
Circle bounding the search that found this edge.
correlated_lat
number
Latitude of the point on the edge the location snapped to.
correlated_lon
number
Longitude of the point on the edge the location snapped to.
distance
number
Distance in meters from the requested point to the snapped point.
edge
object
Graph attributes of the edge.
edge_id
object
Graph identifier of the edge, split into its tile components.
edge_info
object
Names, shape, and OSM way identifiers for the edge.
heading
number
Compass bearing of the edge at the snapped point, in degrees.
inbound_reach
integer
How much of the network can reach this edge, used to detect disconnected islands.
linear_reference
string
OpenLR linear reference for the edge.
live_speed
object
Live traffic speed on the edge, when traffic data is loaded.
outbound_reach
integer
How much of the network this edge can reach.
percent_along
number
How far along the edge the snapped point falls, from 0 to 1.
predicted_speeds
array: number
Historical speed profile for the edge, when one is available.
shoulder
boolean
Whether the edge has a shoulder.
side_of_street
string
Which side of the edge the requested point lies on.
Enumleftrightneither
input_lat
number
Latitude as requested.
input_lon
number
Longitude as requested.
nodes
array: object
Candidate nodes, when the location snaps to an intersection rather than a road.

Example response

Show response
[
  {
    "edges": [
      {
        "access_restrictions": [],
        "bounding_circle": {
          "lat": 37.77919,
          "lon": -122.419962,
          "radius": 90
        },
        "correlated_lat": 37.779214,
        "correlated_lon": -122.419983,
        "distance": 60.8,
        "edge": {
          "access": {
            "HOV": true,
            "bicycle": true,
            "bus": true,
            "car": true,
            "emergency": false,
            "moped": true,
            "motorcycle": true,
            "pedestrian": true,
            "taxi": true,
            "truck": true,
            "wheelchair": true
          },
          "access_restriction": false,
          "bike_network": false,
          "bridge": false,
          "classification": {
            "classification": "trunk",
            "internal": false,
            "link": false,
            "surface": "paved_smooth",
            "use": "road"
          },
          "country_crossing": false,
          "cycle_lane": "none",
          "deadend": false,
          "destination_only": false,
          "destination_only_hgv": false,
          "end_node": {
            "id": 4974,
            "level": 0,
            "tile_id": 2804,
            "value": 166899767200
          },
          "end_restriction": {
            "HOV": false,
            "bicycle": false,
            "bus": false,
            "car": false,
            "emergency": false,
            "moped": false,
            "motorcycle": false,
            "pedestrian": false,
            "taxi": false,
            "truck": false,
            "wheelchair": false
          },
          "forward": true,
          "geo_attributes": {
            "curvature": 3,
            "length": 173,
            "max_down_slope": 0,
            "max_up_slope": 2,
            "weighted_grade": 1.66
          },
          "has_sign": false,
          "lane_count": 3,
          "not_thru": false,
          "part_of_complex_restriction": true,
          "round_about": false,
          "sac_scale": "none",
          "sidewalk_left": false,
          "sidewalk_right": false,
          "speeds": {
            "constrained_flow": 0,
            "default": 40,
            "free_flow": 0,
            "predicted": false,
            "type": "tagged"
          },
          "start_restriction": {
            "HOV": false,
            "bicycle": false,
            "bus": false,
            "car": false,
            "emergency": false,
            "moped": false,
            "motorcycle": false,
            "pedestrian": false,
            "taxi": false,
            "truck": false,
            "wheelchair": false
          },
          "stop_sign": false,
          "toll": false,
          "traffic_signal": false,
          "truck_route": true,
          "tunnel": false,
          "yield_sign": false
        },
        "edge_id": {
          "id": 11635,
          "level": 0,
          "tile_id": 2804,
          "value": 390405838752
        },
        "edge_info": {
          "bike_network": {
            "local": false,
            "mountain": false,
            "national": false,
            "regional": false
          },
          "mean_elevation": 20,
          "names": [
            "US 101 North",
            "Van Ness Avenue"
          ],
          "shape": "k~x`gA~e|nhFg|@hKuI\\}V~C",
          "speed_limit": 40,
          "way_id": 502795544
        },
        "heading": 350.9,
        "inbound_reach": 50,
        "linear_reference": "K6jyJxrdWks/Av/hAJsLT4Q=",
        "live_speed": {},
        "outbound_reach": 50,
        "percent_along": 0.51614,
        "predicted_speeds": [],
        "shoulder": false,
        "side_of_street": "right"
      }
    ],
    "input_lat": 37.7793,
    "input_lon": -122.4193,
    "nodes": []
  }
]

See the Routing Platform overview for API access, travel modes, and the machine-readable schema.

Reference: Valhalla locate API reference