Data visualization with SAS programming

Driving distance between 2 lat & lon points

Reply
Super Contributor
Posts: 400

Driving distance between 2 lat & lon points

Hello,

I have to find a way to calculate the actual driving distance not overhead distance but street driving.  I'm not sure what the best way to approach this would be.

I did see there is a function called Geodist but I'm not sure if that returns the overhead distance or street driving distance.

I'm using sas 9.4 TS1M2.

Thank you for any help you can give me.

SAS Employee
Posts: 170

Re: Driving distance between 2 lat & lon points

GEODIST calculates the straight line distance.  We do not have anything in SAS that calculates the driving distance.

There are some people who have calculated the driving distance using Google Maps, but this is illegal according to Google.

https://developers.google.com/maps/terms?hl=en  (See 10.1.1.H)

Super Contributor
Posts: 400

Re: Driving distance between 2 lat & lon points

Thank you Darrell.

I have been unable to find anything that I could use just with SAS.  I don't want to use a 3rd party site or software due to the sensitivity of my data.

Someone suggested STATA has functions that calculate driving distance so I'm going to look into that.  I guess I could calculate it with STATA then bring it back to SAS for the rest of the work.

Thank you again,

Jerry

SAS Employee
Posts: 340

Re: Driving distance between 2 lat & lon points

To calculate street distances, you will need a graph that describes the length and connections of the streets.

If you have that, you can use shortest path algoritms to find the distance between 2 points or between set of points.

Shortest path algoritms are available in SAS/OR and SAS/SNA.

Super User
Posts: 19,123

Re: Driving distance between 2 lat & lon points

Can you post the reference for how Stata calculates driving distance?

Super Contributor
Posts: 400

Re: Driving distance between 2 lat & lon points

Hi Reeza,

If I'm able to figure it out I will definitely post it here.

Jerry

Valued Guide
Posts: 765

Re: Driving distance between 2 lat & lon points

Hi.  The SAS code posted here once worked great, but Google has once again revised their mapping HTML so I'm still working on fixing it ...

Driving Distances and Drive Times using SAS and Google Maps - sasCommunity

At the bottom of the web page, there's a link to a paper by Ash Roy and Yingbo Na from the Canadian Institute for Health Information in Torontoi ...

Batch Production of Driving Distances and Times Using SAS® and Web Map APIs

http://support.sas.com/resources/papers/proceedings12/091-2012.pdf

There's really no reason to bother with a lot of complicated programming since driving time/distance has all been worked out by Google, Mapquest. etc. and I think it would be a lot easier to write SAS code that uses the an API rather than rebuilding the wheel.

ps  There's a paper that used the SAS code on the SAS Community site that showed that in many cases, straight line distance (as in the GEODIST function) might suffice ... A Nationwide Comparison of Driving Distance Versus Straight-Line Distance to Hospitals

http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3835347/

Super User
Posts: 19,123

Re: Driving distance between 2 lat & lon points

I think it's more of an issue that we're usually not allowed to send addresses to the API - especially in health care as it identifies our patients Smiley Sad

I've heard of people grabbing a yellow pages and using random address mixed with real addresses to help with the anonymize. An option we use as well is driving distances between zip codes - not as exact but close enough for many endeavors.

Ask a Question
Discussion stats
  • 7 replies
  • 609 views
  • 6 likes
  • 5 in conversation