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!!
Calculating Distance between Latitude/Longitude points
Moderators: chulett, rschirm, roy
Re: Calculating Distance between Latitude/Longitude points
There isn't. Some options off the top of my head:mahmudul wrote:I am not sure if there is any built in functions in transformer stage I can use.
1. Roll your own
2. Buy a package
3. Call a web service
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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.
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.
Choose a job you love, and you will never have to work a day in your life. - Confucius
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.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 94
- Joined: Wed May 08, 2002 8:44 am
- Location: Germany
- Contact: