Page 1 of 1

Calculating Distance between Latitude/Longitude points

Posted: Mon Jun 01, 2015 7:46 am
by mahmudul
Hello All,
I am trying to figure out how to calculate distance between Latitude/Longitude points. I am not sure if there is any built in functions in transformer stage I can use. Please advise. Thanks!!

Re: Calculating Distance between Latitude/Longitude points

Posted: Mon Jun 01, 2015 9:09 am
by chulett
mahmudul wrote:I am not sure if there is any built in functions in transformer stage I can use.
There isn't. Some options off the top of my head:

1. Roll your own
2. Buy a package
3. Call a web service

Posted: Mon Jun 01, 2015 9:34 am
by PaulVL
You also need to qualify if you want straight line distance or driving distance.

Posted: Mon Jun 01, 2015 10:50 am
by mahmudul
I need to calculate the distance in miles between two points. It doesn't have to be driving distance.....it can be simply the shortest distance between those two points. Thanks again for your input and feedback!!

Posted: Mon Jun 01, 2015 3:11 pm
by ray.wurlod
You also need to specify whether this is a straight line distance or a great circle (that is, over the surface of the earth, which is curved). There are web services out there that can perform this calculation.

Posted: Mon Jun 01, 2015 3:50 pm
by chulett
Hence suggestion #3! :D

Posted: Tue Jun 02, 2015 2:28 pm
by qt_ky
Use the Pythagorean theorem to calculate a simple distance yourself.

distance = square root of ( (x1 - x2)^2 + (y1 - y2)^2 )

where x and y values are your longitude and latitude decimal numbers.

It may help to use AsFloat() around each x and y value, such as if they are strings vs. decimals.

Then search for a formula to convert the lat/long distance result into miles.

Posted: Wed Jun 10, 2015 5:55 am
by ArndW
When we first created the SDK for DataStage years ago, I got to write some of the functions (which have since been re-written and tuned by engineering) and I had written a distance computation function as well as a Swatch-Time function which were deemed by marketing to be unnecessary and have been dropped. I can't find my sources anymore; and there are several methods of computing distance between two points on a sphere which can produce somewhat different results for points that are far apart. Luckily, all of the basic trigonometric functions you require are part of the BASIC language, so you can just plug-and-play the function you prefer into a user-written program.

Posted: Fri Jun 12, 2015 2:08 am
by Klaus Schaefer
Are you working with a GeoDB or extensions? These usually have functions to calculate all sorts of geometrics.

Klaus