LocationServiceRoutesV2 / Client / calculate_route_matrix
calculate_route_matrix¶
- LocationServiceRoutesV2.Client.calculate_route_matrix(**kwargs)¶
Use
CalculateRouteMatrixto compute results for all pairs of Origins to Destinations. Each row corresponds to one entry in Origins. Each entry in the row corresponds to the route from that entry in Origins to an entry in Destinations positions.For more information, see Calculate route matrix in the Amazon Location Service Developer Guide.
See also: AWS API Documentation
Request Syntax
response = client.calculate_route_matrix( Allow={ 'Hot': True|False, 'Hov': True|False }, Avoid={ 'Areas': [ { 'Geometry': { 'BoundingBox': [ 123.0, ], 'Polygon': [ [ [ 123.0, ], ], ], 'PolylinePolygon': [ 'string', ] } }, ], 'CarShuttleTrains': True|False, 'ControlledAccessHighways': True|False, 'DirtRoads': True|False, 'Ferries': True|False, 'TollRoads': True|False, 'TollTransponders': True|False, 'TruckRoadTypes': [ 'string', ], 'Tunnels': True|False, 'UTurns': True|False, 'ZoneCategories': [ { 'Category': 'CongestionPricing'|'Environmental'|'Vignette' }, ] }, DepartNow=True|False, DepartureTime='string', Destinations=[ { 'Options': { 'AvoidActionsForDistance': 123, 'Heading': 123.0, 'Matching': { 'NameHint': 'string', 'OnRoadThreshold': 123, 'Radius': 123, 'Strategy': 'MatchAny'|'MatchMostSignificantRoad' }, 'SideOfStreet': { 'Position': [ 123.0, ], 'UseWith': 'AnyStreet'|'DividedStreetOnly' } }, 'Position': [ 123.0, ] }, ], Exclude={ 'Countries': [ 'string', ] }, Key='string', OptimizeRoutingFor='FastestRoute'|'ShortestRoute', Origins=[ { 'Options': { 'AvoidActionsForDistance': 123, 'Heading': 123.0, 'Matching': { 'NameHint': 'string', 'OnRoadThreshold': 123, 'Radius': 123, 'Strategy': 'MatchAny'|'MatchMostSignificantRoad' }, 'SideOfStreet': { 'Position': [ 123.0, ], 'UseWith': 'AnyStreet'|'DividedStreetOnly' } }, 'Position': [ 123.0, ] }, ], RoutingBoundary={ 'Geometry': { 'AutoCircle': { 'Margin': 123, 'MaxRadius': 123 }, 'Circle': { 'Center': [ 123.0, ], 'Radius': 123.0 }, 'BoundingBox': [ 123.0, ], 'Polygon': [ [ [ 123.0, ], ], ] }, 'Unbounded': True|False }, Traffic={ 'FlowEventThresholdOverride': 123, 'Usage': 'IgnoreTrafficData'|'UseTrafficData' }, TravelMode='Car'|'Pedestrian'|'Scooter'|'Truck', TravelModeOptions={ 'Car': { 'LicensePlate': { 'LastCharacter': 'string' }, 'MaxSpeed': 123.0, 'Occupancy': 123 }, 'Scooter': { 'LicensePlate': { 'LastCharacter': 'string' }, 'MaxSpeed': 123.0, 'Occupancy': 123 }, 'Truck': { 'AxleCount': 123, 'GrossWeight': 123, 'HazardousCargos': [ 'Combustible'|'Corrosive'|'Explosive'|'Flammable'|'Gas'|'HarmfulToWater'|'Organic'|'Other'|'Poison'|'PoisonousInhalation'|'Radioactive', ], 'Height': 123, 'KpraLength': 123, 'Length': 123, 'LicensePlate': { 'LastCharacter': 'string' }, 'MaxSpeed': 123.0, 'Occupancy': 123, 'PayloadCapacity': 123, 'Trailer': { 'TrailerCount': 123 }, 'TruckType': 'LightTruck'|'StraightTruck'|'Tractor', 'TunnelRestrictionCode': 'string', 'WeightPerAxle': 123, 'WeightPerAxleGroup': { 'Single': 123, 'Tandem': 123, 'Triple': 123, 'Quad': 123, 'Quint': 123 }, 'Width': 123 } } )
- Parameters:
Allow (dict) –
Features that are allowed while calculating a route.
Hot (boolean) –
Allow Hot (High Occupancy Toll) lanes while calculating the route.
Default value:
falseHov (boolean) –
Allow Hov (High Occupancy vehicle) lanes while calculating the route.
Default value:
false
Avoid (dict) –
Features that are avoided while calculating a route. Avoidance is on a best-case basis. If an avoidance can’t be satisfied for a particular case, it violates the avoidance and the returned response produces a notice for the violation. For GrabMaps customers,
ap-southeast-1andap-southeast-5regions support onlyTollRoads,Ferries, andControlledAccessHighways.Areas (list) –
Areas to be avoided.
(dict) –
Area to be avoided.
Geometry (dict) – [REQUIRED]
Geometry of the area to be avoided.
BoundingBox (list) –
Geometry defined as a bounding box. The first pair represents the X and Y coordinates (longitude and latitude,) of the southwest corner of the bounding box; the second pair represents the X and Y coordinates (longitude and latitude) of the northeast corner.
(float) –
Polygon (list) –
Geometry defined as a polygon with only one linear ring.
(list) –
(list) –
(float) –
PolylinePolygon (list) –
A list of Isoline PolylinePolygon, for each isoline PolylinePolygon, it contains PolylinePolygon of the first linear ring (the outer ring) and from second item to the last item (the inner rings). For more information on polyline encoding, see https://github.com/aws-geospatial/polyline.
(string) –
CarShuttleTrains (boolean) –
Avoid car-shuttle-trains while calculating the route.
ControlledAccessHighways (boolean) –
Avoid controlled access highways while calculating the route.
DirtRoads (boolean) –
Avoid dirt roads while calculating the route.
Ferries (boolean) –
Avoid ferries while calculating the route.
TollRoads (boolean) –
Avoids roads where the specified toll transponders are the only mode of payment.
TollTransponders (boolean) –
Avoids roads where the specified toll transponders are the only mode of payment.
TruckRoadTypes (list) –
Truck road type identifiers.
BK1throughBK4apply only to Sweden.A2,A4,B2,B4,C,D,ET2,ET4apply only to Mexico.Note
There are currently no other supported values as of 26th April 2024.
(string) –
Tunnels (boolean) –
Avoid tunnels while calculating the route.
UTurns (boolean) –
Avoid U-turns for calculation on highways and motorways.
ZoneCategories (list) –
Zone categories to be avoided.
(dict) –
Zone categories to be avoided.
Category (string) –
Zone category to be avoided.
DepartNow (boolean) – Uses the current time as the time of departure.
DepartureTime (string) –
Time of departure from the origin.
Time format:
YYYY-MM-DDThh:mm:ss.sssZ | YYYY-MM-DDThh:mm:ss.sss+hh:mmExamples:
2020-04-22T17:57:24Z2020-04-22T17:57:24+02:00Destinations (list) –
[REQUIRED]
List of destinations for the route in World Geodetic System (WGS 84) format: [longitude, latitude].
Note
Route calculations are billed for each origin and destination pair. If you use a large matrix of origins and destinations, your costs will increase accordingly. For more information, see Routes pricing in the Amazon Location Service Developer Guide.
The maximum number of destinations depends on the routing boundary configuration:
With
RoutingBoundary.Geometryset: maximum 500 destinationsWith
RoutingBoundary.Unboundedset totrue: maximum 100 destinationsFor GrabMaps customers in
ap-southeast-1andap-southeast-5: maximum 350 destinations
The total matrix size (origins × destinations) must not exceed:
With
RoutingBoundary.Geometry: 160,000With
RoutingBoundary.Unbounded: 100For GrabMaps customers in
ap-southeast-1andap-southeast-5: 122,500
(dict) –
The route destination.
Options (dict) –
Destination related options. Not supported in
ap-southeast-1andap-southeast-5regions for GrabMaps customers.AvoidActionsForDistance (integer) –
Avoids actions for the provided distance. This is typically to consider for users in moving vehicles who may not have sufficient time to make an action at an origin or a destination.
Heading (float) –
GPS Heading at the position.
Matching (dict) –
Options to configure matching the provided position to the road network.
NameHint (string) –
Attempts to match the provided position to a road similar to the provided name.
OnRoadThreshold (integer) –
If the distance to a highway/bridge/tunnel/sliproad is within threshold, the waypoint will be snapped to the highway/bridge/tunnel/sliproad.
Unit:
metersRadius (integer) –
Considers all roads within the provided radius to match the provided destination to. The roads that are considered are determined by the provided Strategy.
Unit:
metersStrategy (string) –
Strategy that defines matching of the position onto the road network. MatchAny considers all roads possible, whereas MatchMostSignificantRoad matches to the most significant road.
SideOfStreet (dict) –
Options to configure matching the provided position to a side of the street.
Position (list) – [REQUIRED]
Position in World Geodetic System (WGS 84) format: [longitude, latitude].
(float) –
UseWith (string) –
Strategy that defines when the side of street position should be used. AnyStreet will always use the provided position.
Default value:
DividedStreetOnly
Position (list) – [REQUIRED]
Position in World Geodetic System (WGS 84) format: [longitude, latitude].
(float) –
Exclude (dict) –
Features to be strictly excluded while calculating the route. Not supported in
ap-southeast-1andap-southeast-5regions for GrabMaps customers.Countries (list) – [REQUIRED]
List of countries to be avoided defined by two-letter or three-letter country codes.
(string) –
Key (string) – Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.
OptimizeRoutingFor (string) –
Controls the trade-off between finding the shortest travel time (
FastestRoute) and the shortest distance (ShortestRoute) when calculating reachable areas.Default value:
FastestRouteOrigins (list) –
[REQUIRED]
List of origins for the route in World Geodetic System (WGS 84) format: [longitude, latitude].
Note
Route calculations are billed for each origin and destination pair. Using a large amount of Origins in a request can lead you to incur unexpected charges. For more information, see Routes pricing in the Amazon Location Service Developer Guide.
The maximum number of origins depends on the routing boundary configuration:
With
RoutingBoundary.Geometryset: maximum 500 originsWith
RoutingBoundary.Unboundedset totrue: maximum 15 originsFor GrabMaps customers in
ap-southeast-1andap-southeast-5: maximum 350 origins
The total matrix size (origins × destinations) must not exceed:
With
RoutingBoundary.Geometry: 160,000With
RoutingBoundary.Unbounded: 100For GrabMaps customers in
ap-southeast-1andap-southeast-5: 122,500
(dict) –
The start position for the route in World Geodetic System (WGS 84) format: [longitude, latitude].
Options (dict) –
Origin related options. Not supported in
ap-southeast-1andap-southeast-5regions for GrabMaps customers.AvoidActionsForDistance (integer) –
Avoids actions for the provided distance. This is typically to consider for users in moving vehicles who may not have sufficient time to make an action at an origin or a destination.
Heading (float) –
GPS Heading at the position.
Matching (dict) –
Options to configure matching the provided position to the road network.
NameHint (string) –
Attempts to match the provided position to a road similar to the provided name.
OnRoadThreshold (integer) –
If the distance to a highway/bridge/tunnel/sliproad is within threshold, the waypoint will be snapped to the highway/bridge/tunnel/sliproad.
Unit:
metersRadius (integer) –
Considers all roads within the provided radius to match the provided destination to. The roads that are considered are determined by the provided Strategy.
Unit:
metersStrategy (string) –
Strategy that defines matching of the position onto the road network. MatchAny considers all roads possible, whereas MatchMostSignificantRoad matches to the most significant road.
SideOfStreet (dict) –
Options to configure matching the provided position to a side of the street.
Position (list) – [REQUIRED]
Position in World Geodetic System (WGS 84) format: [longitude, latitude].
(float) –
UseWith (string) –
Strategy that defines when the side of street position should be used. AnyStreet will always use the provided position.
Default value:
DividedStreetOnly
Position (list) – [REQUIRED]
Position in World Geodetic System (WGS 84) format: [longitude, latitude].
(float) –
RoutingBoundary (dict) –
Boundary within which the matrix is to be calculated. All data, origins and destinations outside the boundary are considered invalid. For GrabMaps customers,
ap-southeast-1andap-southeast-5regions support onlyUnboundedset totrue.Default value:
Unbounded set to trueNote
When
AutoCircleis set in the request, the response routing boundary will returnCirclederived from theAutoCirclesettings.Geometry (dict) –
Geometry of the area to be avoided.
AutoCircle (dict) –
AutoCirclerequests the route matrix service to define aCircleboundary that best attempts to include most waypoints (OriginsandDestinations) using theAutoCirclesettings. Any waypoints outside of the auto-definedCircleboundary will be considered out of the routing boundary, which results in a route matrix entry error.AutoCircleis only used in the request to configure aCirclefor the route calculation. The derivedCirclewill also be provided in the response.Margin (integer) –
The minimal distance, in meters, between any waypoint and the perimeter of the circle auto-defined for the boundary. Some margin is usually recommended so that the routing has enough leeway to travel from one waypoint to another optimally without conflicting with the routing boundary.
The total of
MaxRadiusandMarginmust be less than or equal to 200,000 meters.MaxRadius (integer) –
The maximum radius, in meters, that the auto-defined
Circleboundary should have, before theMargindistance is added to the circle.The total of
MaxRadiusandMarginmust be less than or equal to 200,000 meters.
Circle (dict) –
Geometry defined as a circle. The circle defines the routing boundary area. Any waypoints outside the circle will result in a route matrix entry error.
You can specify a
Circledirectly in the request, or it will be auto-derived whenAutoCircleis used. WhenAutoCircleis set in the request, the response routing boundary will returnCirclederived from theAutoCirclesettings.Center (list) – [REQUIRED]
Center of the Circle in World Geodetic System (WGS 84) format: [longitude, latitude].
Example:
[-123.1174, 49.2847]represents the position with longitude-123.1174and latitude49.2847.(float) –
Radius (float) – [REQUIRED]
Radius of the Circle.
Unit:
metersValid Range: Minimum value of 0. Maximum value of 200000.
BoundingBox (list) –
Geometry defined as a bounding box. The first pair represents the X and Y coordinates (longitude and latitude,) of the southwest corner of the bounding box; the second pair represents the X and Y coordinates (longitude and latitude) of the northeast corner.
Diagonal distance of the bounding box must be less than or equal to 400,000 meters.
(float) –
Polygon (list) –
Geometry defined as a polygon with only one linear ring. A linear ring is a closed sequence of four or more coordinates. The first and last coordinates are the same, forming a closed boundary. Each coordinate is a position in [longitude, latitude] format.
The structure is an array of linear rings (only 1 allowed). Each linear ring is an array of coordinates (minimum 4), and each coordinate is an array of two doubles [longitude, latitude].
Maximum distance between any two vertices must be less than or equal to 400,000 meters.
(list) –
(list) –
(float) –
Unbounded (boolean) –
No restrictions in terms of a routing boundary, and is typically used for longer routes.
Traffic (dict) –
Traffic related options. Not supported in
ap-southeast-1andap-southeast-5regions for GrabMaps customers.FlowEventThresholdOverride (integer) –
Duration for which flow traffic is considered valid. For this period, the flow traffic is used over historical traffic data. Flow traffic refers to congestion, which changes very quickly. Duration in seconds for which flow traffic event would be considered valid. While flow traffic event is valid it will be used over the historical traffic data.
Usage (string) –
Determines if traffic should be used or ignored while calculating the route.
Default value:
UseTrafficData
TravelMode (string) –
Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. For GrabMaps customers,
ap-southeast-1andap-southeast-5regions support onlyCar,Pedestrian, andScooter.Default value:
CarTravelModeOptions (dict) –
Travel mode related options for the provided travel mode. Not supported in
ap-southeast-1andap-southeast-5regions for GrabMaps customers.Car (dict) –
Travel mode options when the provided travel mode is
Car.LicensePlate (dict) –
The vehicle License Plate.
LastCharacter (string) –
The last character of the License Plate.
MaxSpeed (float) –
Maximum speed
Unit:
kilometers per hourOccupancy (integer) –
The number of occupants in the vehicle.
Default value:
1
Scooter (dict) –
Travel mode options when the provided travel mode is
Scooter.Note
When travel mode is set to
Scooter, then the avoidance optionControlledAccessHighwaysdefaults totrue.LicensePlate (dict) –
The vehicle License Plate.
LastCharacter (string) –
The last character of the License Plate.
MaxSpeed (float) –
Maximum speed.
Unit:
kilometers per hourOccupancy (integer) –
The number of occupants in the vehicle.
Default value:
1
Truck (dict) –
Travel mode options when the provided travel mode is
Truck.AxleCount (integer) –
Total number of axles of the vehicle.
GrossWeight (integer) –
Gross weight of the vehicle including trailers, and goods at capacity.
Unit:
kilogramsHazardousCargos (list) –
List of Hazardous cargo contained in the vehicle.
(string) –
Height (integer) –
Height of the vehicle.
Unit:
centimetersKpraLength (integer) –
Kingpin to rear axle length of the vehicle
Unit:
centimetersLength (integer) –
Length of the vehicle.
Unit:
centimetersLicensePlate (dict) –
The vehicle License Plate.
LastCharacter (string) –
The last character of the License Plate.
MaxSpeed (float) –
Maximum speed
Unit:
kilometers per hourOccupancy (integer) –
The number of occupants in the vehicle.
Default value:
1PayloadCapacity (integer) –
Payload capacity of the vehicle and trailers attached.
Unit:
kilogramsTrailer (dict) –
Trailer options corresponding to the vehicle.
TrailerCount (integer) –
Number of trailers attached to the vehicle.
Default value:
0
TruckType (string) –
The type of truck:
LightTruckfor smaller delivery vehicles,StraightTruckfor rigid body trucks, orTractorfor tractor-trailer combinations.TunnelRestrictionCode (string) –
The tunnel restriction code.
Tunnel categories in this list indicate the restrictions which apply to certain tunnels in Great Britain. They relate to the types of dangerous goods that can be transported through them.
Tunnel Category B
Risk Level: Limited risk
Restrictions: Few restrictions
Tunnel Category C
Risk Level: Medium risk
Restrictions: Some restrictions
Tunnel Category D
Risk Level: High risk
Restrictions: Many restrictions occur
Tunnel Category E
Risk Level: Very high risk
Restrictions: Restricted tunnel
WeightPerAxle (integer) –
Heaviest weight per axle irrespective of the axle type or the axle group. Meant for usage in countries where the differences in axle types or axle groups are not distinguished.
Unit:
kilogramsWeightPerAxleGroup (dict) –
Specifies the total weight for the specified axle group. Meant for usage in countries that have different regulations based on the axle group type.
Single (integer) –
Total weight in kilograms for single axle configurations.
Unit:
kilogramsTandem (integer) –
Total weight in kilograms for tandem (two adjacent) axle configurations.
Unit:
kilogramsTriple (integer) –
Total weight in kilograms for triple (three adjacent) axle configurations.
Unit:
kilogramsQuad (integer) –
Total weight in kilograms for quad (four adjacent) axle configurations.
Unit:
kilogramsQuint (integer) –
Total weight in kilograms for quint (five adjacent) axle configurations.
Unit:
kilograms
Width (integer) –
Width of the vehicle.
Unit:
centimeters
- Return type:
dict
- Returns:
Response Syntax
{ 'ErrorCount': 123, 'PricingBucket': 'string', 'RouteMatrix': [ [ { 'Distance': 123, 'Duration': 123, 'Error': 'NoMatch'|'NoMatchDestination'|'NoMatchOrigin'|'NoRoute'|'OutOfBounds'|'OutOfBoundsDestination'|'OutOfBoundsOrigin'|'Other'|'Violation' }, ], ], 'RoutingBoundary': { 'Geometry': { 'AutoCircle': { 'Margin': 123, 'MaxRadius': 123 }, 'Circle': { 'Center': [ 123.0, ], 'Radius': 123.0 }, 'BoundingBox': [ 123.0, ], 'Polygon': [ [ [ 123.0, ], ], ] }, 'Unbounded': True|False } }
Response Structure
(dict) –
ErrorCount (integer) –
The count of error results in the route matrix. If this number is 0, all routes were calculated successfully.
PricingBucket (string) –
The pricing bucket for which the query is charged at.
RouteMatrix (list) –
The calculated route matrix containing the results for all pairs of Origins to Destination positions. Each row corresponds to one entry in Origins. Each entry in the row corresponds to the route from that entry in Origins to an entry in Destination positions.
(list) –
(dict) –
The calculated route matrix containing the results for all pairs of Origins to Destination positions. Each row corresponds to one entry in Origins. Each entry in the row corresponds to the route from that entry in Origins to an entry in Destination positions.
Distance (integer) –
The total distance of travel for the route.
Duration (integer) –
The expected duration of travel for the route.
Unit:
secondsError (string) –
Error code that occurred during calculation of the route.
RoutingBoundary (dict) –
Boundary within which the matrix is to be calculated. All data, origins and destinations outside the boundary are considered invalid.
Note
When
AutoCircleis set in the request, the response routing boundary will returnCirclederived from theAutoCirclesettings.Geometry (dict) –
Geometry of the area to be avoided.
AutoCircle (dict) –
AutoCirclerequests the route matrix service to define aCircleboundary that best attempts to include most waypoints (OriginsandDestinations) using theAutoCirclesettings. Any waypoints outside of the auto-definedCircleboundary will be considered out of the routing boundary, which results in a route matrix entry error.AutoCircleis only used in the request to configure aCirclefor the route calculation. The derivedCirclewill also be provided in the response.Margin (integer) –
The minimal distance, in meters, between any waypoint and the perimeter of the circle auto-defined for the boundary. Some margin is usually recommended so that the routing has enough leeway to travel from one waypoint to another optimally without conflicting with the routing boundary.
The total of
MaxRadiusandMarginmust be less than or equal to 200,000 meters.MaxRadius (integer) –
The maximum radius, in meters, that the auto-defined
Circleboundary should have, before theMargindistance is added to the circle.The total of
MaxRadiusandMarginmust be less than or equal to 200,000 meters.
Circle (dict) –
Geometry defined as a circle. The circle defines the routing boundary area. Any waypoints outside the circle will result in a route matrix entry error.
You can specify a
Circledirectly in the request, or it will be auto-derived whenAutoCircleis used. WhenAutoCircleis set in the request, the response routing boundary will returnCirclederived from theAutoCirclesettings.Center (list) –
Center of the Circle in World Geodetic System (WGS 84) format: [longitude, latitude].
Example:
[-123.1174, 49.2847]represents the position with longitude-123.1174and latitude49.2847.(float) –
Radius (float) –
Radius of the Circle.
Unit:
metersValid Range: Minimum value of 0. Maximum value of 200000.
BoundingBox (list) –
Geometry defined as a bounding box. The first pair represents the X and Y coordinates (longitude and latitude,) of the southwest corner of the bounding box; the second pair represents the X and Y coordinates (longitude and latitude) of the northeast corner.
Diagonal distance of the bounding box must be less than or equal to 400,000 meters.
(float) –
Polygon (list) –
Geometry defined as a polygon with only one linear ring. A linear ring is a closed sequence of four or more coordinates. The first and last coordinates are the same, forming a closed boundary. Each coordinate is a position in [longitude, latitude] format.
The structure is an array of linear rings (only 1 allowed). Each linear ring is an array of coordinates (minimum 4), and each coordinate is an array of two doubles [longitude, latitude].
Maximum distance between any two vertices must be less than or equal to 400,000 meters.
(list) –
(list) –
(float) –
Unbounded (boolean) –
No restrictions in terms of a routing boundary, and is typically used for longer routes.
Exceptions