cancel
Showing results for 
Search instead for 
Did you mean: 

Data Services address/geocode distance calculation functionality

brad_schroeter2
Explorer
0 Kudos

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...

Accepted Solutions (0)

Answers (3)

Answers (3)

brad_schroeter2
Explorer
0 Kudos

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

And here's the Python editor:

former_member492038
Participant
0 Kudos

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
kalpesh_pandey
Contributor
0 Kudos

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

brad_schroeter2
Explorer
0 Kudos

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.