Skip to Content
0

Data Services address/geocode distance calculation functionality

Feb 24, 2017 at 04:52 PM

117

avatar image

From my understanding, Data Services cannot calculate the distance between two addresses/geocodes (i.e. there's no out of the box transform or function). Has anyone come up with a solution to do this in Data Services? Thanks...

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Brad Schroeter Mar 09, 2017 at 09:23 PM
0

DS doesn't have the built-in math functions to do this via a custom function. So I ended up using the user-defined transform and writing Python code.

Share
10 |10000 characters needed characters left characters exceeded
Kalpesh Pandey May 31, 2017 at 04:55 PM
0

Hi Brad, We have almost the same requirement to find distances between two Zip codes. Can you share anything to get insight how to do this?

Thanks,

Kalpesh

Share
10 |10000 characters needed characters left characters exceeded
Brad Schroeter Sep 01, 2017 at 08:20 PM
0

I created a user-defined transform which looks like this:

And here's the Python editor:


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Brad - glad this works but just a couple suggestions:

  • Don't create the variables "= locals()" and especially don't modify them beyond that. Locals() is internal to Python and their documentation specifically mentions that it should not be modified, which you are doing in your code
  • It doesn't look like your variables need to be dictionary objects at all, so instead of "latitude1[u"LATITUDE"]" just create a variable called "latitude"
  • You don't need to call "del var" on all your variables. Python garbage collects its variables so this doesn't do what you expect, and is considered "unpythonic" to make this type of call
0