Calculation of distance using lat long in tableau

喜你入骨 提交于 2019-12-11 02:54:16

问题


I have a data file with millions of rows with lat and long columns as 2 of the field in the columns.

Would like to ask if there is any ways to calculate the total distance for (e.g. Model X "Index 0 --> Index1 , Index 1--> Index 3" ) using the lat long field

Index,Model,lat,long
0,X,1.3539,103.84
1,X,1.3545,103.84
2,Y,1.3839,103.7002
3,X,1.3548,103.84
4,Y,1.3831,103.71
5,Z,1.3139,103.88

Please advice!


回答1:


This formula will calculate distance. But to make it work, you'll need to either use the lookup() function to look at the next row or somehow pivot your data so that you have two sets of coordinates on the same row.

3959 * ACOS 
( 
SIN(RADIANS([Lat])) * SIN(RADIANS([Lat2])) + 
COS(RADIANS([Lat])) * COS(RADIANS([Lat2])) * COS(RADIANS([Long2]) - RADIANS([Long])) 
)



回答2:


Although you certainly can perform geospatial geometric calculations as calcs in Tableau, for large data sets and a scalable performance, the better approach is to store the data in a database with geospatial functionality built-in. You can then access that functionality efficiently from Tableau - although you might need to use custom SQL if Tableau's database driver does not yet natively access the geospatial features of your particular database. Not really a large problem,

Some databases with geospatial support are PostGIS, Oracle and SQL Server.



来源:https://stackoverflow.com/questions/50831454/calculation-of-distance-using-lat-long-in-tableau

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!