0

I am using AWS Location Services Route Calculator to determine travel time and travel distance of several origin destination pairs. The code is working but it is not reflecting travel delay due to traffic. It calculates the difference between two cities with departure time at 2 AM and 11 AM are only a couple minutes of time difference. Doing the same search manually in Here Maps shows the same times but the 11 am departure time shows a significant delay like +40 minutes probably due to traffic. Is this data available in the AWS api?

Town1   Town2       Mile 2  Mile 8  Mile 16 Mile 23 Time 2  Time 8  Time 16 Time 23
ACTON   CHARLEMONT  86.56   86.56   87.98   87.98   103.68  103.89  104.95  104.31
ACTON   CHARLESTOWN 23.43   23.43   22.98   23.43   38.09   38.14   44.33   42.89


def initialize_amazon_client(aws_access_key_id, aws_secret_access_key):
    """Initialize and return an Amazon Location Service client."""
    session = boto3.Session(
        aws_access_key_id=aws_access_key_id,
        aws_secret_access_key=aws_secret_access_key,
        region_name='us-east-1'
    )

    return session.client('location')


client = initialize_amazon_client(aws_access_key_id, aws_secret_access_key)


response = client.calculate_route(
        CalculatorName=calculator_name,
        DeparturePosition=origin,
        DestinationPosition=destination,
        TravelMode='Car',
        DepartNow=False,
        DepartureTime=departure_time,
        DistanceUnit='Miles',
        CarModeOptions={
            'AvoidFerries': False,
            'AvoidTolls': False
        }
    )

1 Answer 1

1

From Routes - Amazon Location Service:

Traffic and departure time

The Amazon Location Service takes traffic into account when calculating a route. The trafffic that it considers is based on the time that you specify. You can specify to depart now, or you can provide a specific time that you want to leave, which will affect the route result by adjusting for traffic at the specified time.

And from Departure time - Amazon Location Service:

You can set a specific a departure time to use live and predictive traffic conditions from your chosen data provider, by using one of the following options:

DepartNow – When set to true, it uses live traffic conditions to calculate the fastest travel path.

DepartureTime – When provided, it uses predictive and known traffic conditions for the requested time. Defined in the following format: YYYY-MM-DDThh:mm:ss.sssZ

So, it seems that live traffic will only be used if you are estimating route 'now'. Otherwise, it is 'expected' traffic levels.

Sign up to request clarification or add additional context in comments.

2 Comments

Hello @John Rotenstein, whether the departure time is now or a future time, like next Monday. The issue I am having is with the route estimated for now and departure time do not differ, "Town1 Town2 Mile (02AM) Mile (08AM) Mile (04PM) Mile (11PM) Time (02AM) Time (08AM) Time (04PM) Time (11PM) ACTON CHARLEMONT 86.56 86.56 87.98 87.98 103.68 103.89 104.95 104.31 ACTON CHARLESTOWN 23.43 23.43 22.98 23.43 38.09 38.14 44.33 42.89 ACTON CHARLTON 46.64 46.64 46.64 46.64 51.15 51.22 53.41 52.15 " = The route calculation shows same time for 2 am and 4pm, route is going through major cities.
Also, fyi I tried using both HERE and Esri data sources for the Route Calculator and Places index, and they both are giving similar results, no traffic delay is reflected in the travel time calculation for departure time 2 am vs 4 pm or any other city rush hour traffic hours. 2 am and 4pm show same travel time with the calculation with the api, but if I manually search with these departure times, 4pm shows +40 minutes delay, 2am shows no delay, but they both show the same base travel time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.