Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating distance using Latitude and Longitude

Hi All

I have a set of recorde where, i want to calculate the distance using latitude and longitude.

   

employeidnamestateDistrictLatitudeLongitude
1johnasdnewyork22.37114.12
2rickyadsdcarolina22.36114.13
3patrikaffdfWDC22.32114.21
4michealagffsfLondon22.32114.16
5harryaddsdsdfsHong Kong22.28114.18
1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

No your result isn´t correct, see attached qvw file!

The distance is set to kilometers. You can check this with online tools like:

nhc.noaa.gov/gccalc.shtml

Unbenannt.png

View solution in original post

10 Replies
Frank_Hartmann
Master II
Master II

not sure which distances you need to calculate but johnw posted a very nice approach here:

Haversine formula to find distance between two lat/long points

hope this helps!

Not applicable
Author

this is my requirement  exatly

I have a data as below

Tanle1

Employee  latitude  longitude

Arnold           121          130

Beck               150           72

Table 2

Factory    f_latitude  f_longitude

A                211.7          179.5

B                 129             150

I want to calculate the distance from Arnold to both the factories A and B

the distance from Beck to both the factories A and B


Is it possible to do and there is no relation between the two tables

Frank_Hartmann
Master II
Master II

are you sure about the latitude values because latitude cannot exceed 90 degrees!

I adapted the above mentioned qvw with random latitude values!

hope this helps

Not applicable
Author

Yeah the values are wrong my assumed values and if i have 50 employees and 50 Factories can we get all the distances between all employess to all the factories

Frank_Hartmann
Master II
Master II

yes, see above posted qvw!

Not applicable
Author

Hi Frank,

I have the data as follows

emp-tab:

emp_id, lat1, long1
1, 22.32, 114.17
2, 22.28, 114.16

factory_tab:

Fact_ID, lat2, long2
1, 22.42544, 114.23134
2, 22.29540, 114.26860

i'm getting the end results as

is this correct and what format is this distance in  is it miles

Frank_Hartmann
Master II
Master II

No your result isn´t correct, see attached qvw file!

The distance is set to kilometers. You can check this with online tools like:

nhc.noaa.gov/gccalc.shtml

Unbenannt.png

Not applicable
Author

Hi Frnak, i have two different tables in my senario

can't we achieve if the the dat is in two different tables

Not applicable
Author

Hi Frank i got it, i forget to do this calculation  *pi()/180

in the second table