BookmarkSubscribeRSS Feed
stuart_snap
Fluorite | Level 6

Hi,

 

I am working on location optimization and using drive times and distances from Google maps.  I got lots of useful info from the oft quoted Mike Zdeb at http://www.sascommunity.org/wiki/Driving_Distances_and_Drive_Times_using_SAS_and_Google_Maps.  Very helpful and works well!

 

Part of process involves taking the Google Maps output for a search between the 2 addresses.  You then use the scan function to parse out the driving distance and time.  Straight forward enough.  I am curious, however, about the results and hoping some community folks have some additional Google Maps experience.  The results from the searches typically have multiple times and distances.  Most examples use just the first time and distance... but does anyone know what the second  (or third, forth, etc) times represent?  Sometimes it looks like the first time/distance is an average... but other times the math doesn't work for it be an average. 

 

There are couple examples below..

 

1) [35574,"22.1 miles",1],[1800,"30 min"],0,null,null,[[1712,"29 min"],1,3,[1620,"27 min"],[1563,2162,"26 - 36 min"]

2) [101519,"63.1 miles",1],[4650,"1 h 18 min"],0,null,null,[[5136,"1 h 26 min"],2,2,[4269,"1 h 11 min"],[4308,5797,"1 h 12 min - 1 h 37 min"]

 

Additionally, most the time, the distance isn't exactly what is listed when you just run the search in Google Maps.  It is usually close, but using the address in example 2, I get a distance distances of 58.3 miles and 63.7 with times of 1H39M and 1H20M.

 

I recognize that drive times are educated guesses and I am not overly reliant on them. Just trying to understand the data and differences between direct searches and SAS grabbing it .  Any Google Maps experts out there they have any insights?  Any good resources on the topic?  Thanks!

3 REPLIES 3
Reeza
Super User

 The results from the searches typically have multiple times and distances.

 

Typically, when you search for a driving route there may be multiple alternative routes. So the recommended is #1 and then the alternatives are the other suggested routes, with the different times. 

 

Also, Google will sometimes auto correct addresses so that what you get is not what you expect but probably close enough. 

Because of possible settings, ie avoid highways, avoid busy areas, you may get different first 'records' unless you've made sure they're consistently set.

 

Note that this type of usage violates Googles Terms of Service, so if you're using this for a work product that may be a significant roadblock/issue you need to deal with. I don't believe Open StreetMaps has this restriction.

ChrisHemedinger
Community Manager

Ditto what @Reeza said re: web scraping and Google's T&Cs.  However, they do offer a Google Distance Matrix API -- account required -- that provides a more reliable, structured response.  I think the account is required for rate-limiting purposes, and doesn't cost anything for a small number of API calls.  With PROC HTTP and the JSON libname engine, you can build a nice reliable SAS program to fetch this info.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
stuart_snap
Fluorite | Level 6

Thanks Reeza and Chris. 

 

Luckily, we do have an API account.... I am just doing some feasibility testing and understanding the data (Drive distance vs geodistance, how accurate it "feels" etc.) before we do anything. 

 

Thank you!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 903 views
  • 2 likes
  • 3 in conversation