Jonathan Guthrie Posted June 12 Share Posted June 12 I have a customer who was upgraded to 14.4 yesterday and his previously working dxp (which FYI also runs OK in my 14.3) is throwing the following error in 14.4 Spotfire Enterprise Runtime for R returned an error (2) The data function '[Geospatial] Distance Matrix' could not be executed. Error in .package.execute.initialization.function(ns, ".onLoad", dirn : error executing function '.onLoad' from package 'glue' loaded from C:/Users/jedga/DOCUME~1/TERR/x86_64-w64-mingw32-library/6.1 : Error in registerS3method(generic, class, fun, envir = asNamespace(pk... : object 'vec_ptype2' not found I have checked his Managed Trust and the Required packages for R: `geosphere`, `dplyr`, `tidyr` are installed. Thoughts/Ideas - looks to me like a 14.4 TERR library issue from the upgrade Link to comment Share on other sites More sharing options...
David Boot-Olazabal Posted June 12 Share Posted June 12 Hi Jonathan, We have been able to reproduce the same error. Not sure if it is related to the TERR library or not. But could you create a support ticket for this problem via https://support.tibco.com? Kind regards, David Link to comment Share on other sites More sharing options...
David Boot-Olazabal Posted June 12 Share Posted June 12 Hi Jonathan, An update from our side, after a bit more testing. It seems that the dplyr and tidyr packages won't upgrade. That might be a good thing to add in the ticket. Also, would an alternative, using Python for instance, also be a workable solution for you and your customer? Kind regards, David Link to comment Share on other sites More sharing options...
Jonathan Guthrie Posted June 12 Author Share Posted June 12 Support ticket raised Case 02281423 Link to comment Share on other sites More sharing options...
Jonathan Guthrie Posted June 12 Author Share Posted June 12 Currently reviewing the python option https://pypi.org/project/geodistpy/ as an alternative for the Spotfire Community Exchange R [Geospatial] Distance Matrix data function. Link to comment Share on other sites More sharing options...
Solution Gaia Paolini Posted June 12 Solution Share Posted June 12 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) Link to comment Share on other sites More sharing options...
Jonathan Guthrie Posted June 13 Author Share Posted June 13 Thanks Gaia - sadly I got an error installing the spotfire-dsml package Link to comment Share on other sites More sharing options...
Gaia Paolini Posted June 13 Share Posted June 13 thanks for alerting, will check Link to comment Share on other sites More sharing options...
Jonathan Guthrie Posted June 14 Author Share Posted June 14 Completely removed my Spotfire Analyst 14.3 installation including the Appdata Spotfire directory and did a clean install of Spotfire Analyst 14.4 Following the 14.4 install I looked to install geosphere, dplyr, tidyr for the R [Geospatial] Distance Matrix function - those packages were already there. The R data function still errors with the same object 'vec_ptype2' not found error as before. Moving to the Python packages I saw that spotfire-dsml was already there. Plumbed in the data function code provided by Gaia - thank you - and it is working. One question - I am assuming the haversine in the spotfire-dsml returns the distance in meters as did the R version. Is this correct? [Geospatial Python] Distance Matrix.sfd Link to comment Share on other sites More sharing options...
Gaia Paolini Posted June 14 Share Posted June 14 Excellent! Yes, I set unit='m' in the code I gave you; you can set units in meters, kilometers or miles or feet (with various spelling and abbreviations). It's all pretty new so documentation examples etc are still being processed. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now