Distance matrix is showing (-1) value for distance and time.

• Question

• I have used Bing API for distance matrix. I am using key from the basic, Dev/Test option. I am running a python script for constructing a distance matrix, however, most of the values are -1. Why? What to do?

This is the URL from my code.

url = "https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins="+str(lat_o)+","+str(lon_o)+"&destinations="+str(lat_d)+","+str(lon_d)+"&travelMode=driving&key=<Key>"

Thursday, October 1, 2020 11:12 AM

All replies

• My suspicion is some of the locations you have are not routable.  When you check those locations do they resolve to a road or near to a road location?
Thursday, October 1, 2020 4:54 PM
• Correct, I recall the service returns -1 in situations where a route can't be calculated between two points.
Thursday, October 1, 2020 6:57 PM
• I infact put the locations on roads, still lot of locations are returning -1. I mean how should I make them routable. they are right there on road :/
Saturday, October 10, 2020 5:56 PM
• Two points located on road and showing a route on google map, but when I am using bing API it is returning -1. I have take lat and longs from mymaps (google) and then used bing api (through python script). Do you think getting lat and long from bing map would help? I mean ultimately it comes down to lat and long and it should not matter the source from which I obtain them, right?
Saturday, October 10, 2020 5:59 PM
• Hi Kaveri,

Bing Maps will use a narrow definition for whether a point is routable or not.  Our locations API will provide a UsageType such as the sample

<GeocodePoint> <Latitude>47.640568390488625</Latitude> <Longitude>-122.1293731033802</Longitude> <CalculationMethod>Interpolation</CalculationMethod> <UsageType>Display</UsageType> <UsageType>Route</UsageType> </GeocodePoint>

You will want to provide the point with usgaeType "Route" as a Location point can be in the center of a building which is not routable.

Sincerely,

IoTGirl

Monday, October 12, 2020 4:29 PM