cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data Services address/geocode distance calculation functionality

brad_schroeter2
Explorer
0 Likes
916

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

View Entire Topic
brad_schroeter2
Explorer
0 Likes

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

And here's the Python editor:

former_member492038
Participant
0 Likes

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