Skip to content
Documentation

Expansion

Available on the following API tiers:

Transitland v2Beta

Return the edges a routing or isochrone search explored, as GeoJSON. Useful for visualizing and debugging searches.

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

Return the edges explored while answering a routing request, as GeoJSON. Useful for understanding why a route was chosen.

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.

action
string
Algorithm to expand.
Required
Enumrouteisochronesources_to_targets
dedupe
boolean
Emit each edge only once.
Defaultfalse
expansion_properties
array: string
GeoJSON property key to include in the expansion response. Each additional property increases output size by roughly 10%. By default an empty properties object is returned.
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).
skip_opposites
boolean
Skip reverse-direction edges in the output.
Defaultfalse
costing
string
Not available here: multimodal — transit routing is served by the Transitland Routing API at /otp/plan, not by this engine.
Required
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/expansion" \
  -H "apikey: YOUR_API_KEY" \
  --data-urlencode 'json={"action":"isochrone","contours":[{"time":0.3}],"costing":"auto","expansion_properties":["duration","distance","cost","edge_id","pred_edge_id","edge_status","expansion_type","flow_sources","travel_mode","expansion_index"],"locations":[{"lat":37.7793,"lon":-122.4193}]}'

Response

features
array: object
One feature per explored edge.
geometry
object
A GeoJSON geometry, per RFC 7946.
properties
object
One key per requested expansion property.
type
string
GeoJSON feature type.
EnumFeature
geometry
object
A GeoJSON geometry, per RFC 7946.
properties
object
One key per requested expansion property.
type
string
GeoJSON feature type.
EnumFeature
properties
object
Collection-level metadata about the expansion.
type
string
GeoJSON collection type.
EnumFeatureCollection

Example response

Show response
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          [
            -122.419824,
            37.778422
          ],
          [
            -122.420116,
            37.779956
          ]
        ],
        "type": "LineString"
      },
      "properties": {
        "cost": 9,
        "distance": 83,
        "duration": 7,
        "edge_id": 390405838752,
        "edge_status": "s",
        "expansion_index": 0,
        "expansion_type": 0,
        "flow_mask_constrained": false,
        "flow_mask_current": false,
        "flow_mask_free_flow": false,
        "flow_mask_predicted": false,
        "pred_edge_id": 70368744177663,
        "travel_mode": "unknown"
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "coordinates": [
          [
            -122.420116,
            37.779956
          ],
          [
            -122.420154,
            37.780089
          ]
        ],
        "type": "LineString"
      },
      "properties": {
        "cost": 10,
        "distance": 98,
        "duration": 8,
        "edge_id": 390204512160,
        "edge_status": "s",
        "expansion_index": 0,
        "expansion_type": 0,
        "flow_mask_constrained": false,
        "flow_mask_current": false,
        "flow_mask_free_flow": false,
        "flow_mask_predicted": false,
        "pred_edge_id": 390405838752,
        "travel_mode": "unknown"
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "coordinates": [
          [
            -122.420154,
            37.780089
          ],
          [
            -122.420183,
            37.780196
          ]
        ],
        "type": "LineString"
      },
      "properties": {
        "cost": 12,
        "distance": 110,
        "duration": 11,
        "edge_id": 389231433632,
        "edge_status": "s",
        "expansion_index": 0,
        "expansion_type": 0,
        "flow_mask_constrained": false,
        "flow_mask_current": false,
        "flow_mask_free_flow": false,
        "flow_mask_predicted": false,
        "pred_edge_id": 390204512160,
        "travel_mode": "unknown"
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "coordinates": [
          [
            -122.420154,
            37.780089
          ],
          [
            -122.420084,
            37.780093
          ]
        ],
        "type": "LineString"
      },
      "properties": {
        "cost": 16,
        "distance": 104,
        "duration": 14,
        "edge_id": 314539611785,
        "edge_status": "s",
        "expansion_index": 0,
        "expansion_type": 0,
        "flow_mask_constrained": false,
        "flow_mask_current": false,
        "flow_mask_free_flow": false,
        "flow_mask_predicted": false,
        "pred_edge_id": 390204512160,
        "travel_mode": "unknown"
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "coordinates": [
          [
            -122.420183,
            37.780196
          ],
          [
            -122.420261,
            37.780582
          ]
        ],
        "type": "LineString"
      },
      "properties": {
        "cost": 17,
        "distance": 154,
        "duration": 15,
        "edge_id": 390338729888,
        "edge_status": "s",
        "expansion_index": 0,
        "expansion_type": 0,
        "flow_mask_constrained": false,
        "flow_mask_current": false,
        "flow_mask_free_flow": false,
        "flow_mask_predicted": false,
        "pred_edge_id": 389231433632,
        "travel_mode": "unknown"
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "coordinates": [
          [
            -122.420261,
            37.780582
          ],
          [
            -122.42034,
            37.780969
          ]
        ],
        "type": "LineString"
      },
      "properties": {
        "cost": 21,
        "distance": 198,
        "duration": 19,
        "edge_id": 389164324768,
        "edge_status": "s",
        "expansion_index": 0,
        "expansion_type": 0,
        "flow_mask_constrained": false,
        "flow_mask_current": false,
        "flow_mask_free_flow": false,
        "flow_mask_predicted": false,
        "pred_edge_id": 390338729888,
        "travel_mode": "unknown"
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "coordinates": [
          [
            -122.420084,
            37.780093
          ],
          [
            -122.419707,
            37.780138
          ]
        ],
        "type": "LineString"
      },
      "properties": {
        "cost": 21,
        "distance": 138,
        "duration": 18,
        "edge_id": 316787758729,
        "edge_status": "s",
        "expansion_index": 0,
        "expansion_type": 0,
        "flow_mask_constrained": false,
        "flow_mask_current": false,
        "flow_mask_free_flow": false,
        "flow_mask_predicted": false,
        "pred_edge_id": 314539611785,
        "travel_mode": "unknown"
      },
      "type": "Feature"
    }
  ],
  "properties": {
    "algorithm": "dijkstras"
  },
  "type": "FeatureCollection"
}

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

Reference: Valhalla expansion API reference