We have a Python option in the newly released spotfire-dsml library.
What you need to do is install spotfire-dsml via Spotfire (Menu > Tools > Python Tools > Package Management).
Then use the following data function (the only slight modification I made to the code is to de-duplicate any id vector, as it expects unique ids):
The distance method could be: 'haversine' (similar to the old TERR version), 'haversine_r' (slightly slower but more accurate) or 'geodesic' (slowest and most accurate).
If buffer is not None, it applies a buffer cutoff to the returned distance matrix.
Other than that, the inputs are the latitude, longitude and id for each dataset (lat1,lon1,id1,lat2,lon2,id2).
# Import modules
from spotfire_dsml.geo_analytics import distances, crs_utilities
import pandas as pd
# Make sure ids are not duplicated
def deduplicate_id(id):
id_list = list(id)
map_list = map(lambda x: x[1]+ "_" + str(id_list[:x[0]].count(x[1]) + 1) if id_list.count(x[1]) > 1 else x[1], enumerate(id_list))
return list(map_list)
id1 = deduplicate_id(id1)
id2 = deduplicate_id(id2)
distance_method='haversine'
crs='EPSG:4326'
unit='m'
buffer=None
distance_matrix = distances.calculate_distance_matrix(crs,unit,buffer,distance_method,lat1,
lon1,id1,lat2,lon2,id2)