Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to calculate approximate distance with latitude and longitude

from math import cos, sqrt
def qick_distance(Lat1, Long1, Lat2, Long2):
    x = Lat2 - Lat1
    y = (Long2 - Long1) * cos((Lat2 + Lat1)*0.00872664626)  
    return 111.319 * sqrt(x*x + y*y)
Comment

how to calculate approximate distance with latitude and longitude

const R = 6371e3; // metres
const φ1 = lat1 * Math.PI/180; // φ, λ in radians
const φ2 = lat2 * Math.PI/180;
const Δφ = (lat2-lat1) * Math.PI/180;
const Δλ = (lon2-lon1) * Math.PI/180;

const a = Math.sin(Δφ/2) * Math.sin(Δφ/2) +
          Math.cos(φ1) * Math.cos(φ2) *
          Math.sin(Δλ/2) * Math.sin(Δλ/2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

const d = R * c; // in metres
Comment

PREVIOUS NEXT
Code Example
Python :: django check if get parameter exists 
Python :: python keyboard input arrow keys 
Python :: python multiply each item in list 
Python :: numpy make 2d array 1d 
Python :: python split at index 
Python :: data frame 
Python :: python how to make integer show 2 numbers 
Python :: python print variable 
Python :: how to make a list in python 
Python :: python template strings 
Python :: return position of a unique value in python array 
Python :: dictionary append value python 
Python :: string.format() with {} inside string as string 
Python :: sets in python 
Python :: re.search() 
Python :: python library to convert decimal into octal and hexadecimal 
Python :: if key not in dictionary python 
Python :: python requests response 503 
Python :: how to invert a true false array in python 
Python :: return python meaning 
Python :: python subprocess 
Python :: python choose function 
Python :: django httpresponse 
Python :: pandas to csv 
Python :: API curl python pandas 
Python :: python select columns names from dataframe 
Python :: pandas define how you want to aggregate each column 
Python :: numpy savetext in one line 
Python :: pandas join two dataframes 
Python :: fetch firestore indexes 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =