Q:

how to find user location within 500 meters from given lat and long in python

I want to find a user location within 500 meters from given lat and long in Python. 
Given lat & long = 19.114315,72.911174
And I want to check whether new lat and long is in the range of 500 meters from given lat and long..
new lat and long = 19.112398,72.912743
I am using this formula in python..
math.acos(math.sin(19.114315) * math.sin(19.112398) + math.cos(19.114315) * math.cos(19.112398) * math.cos(72.912743 - (72.911174))) * 6371 <= 0.500 

But its not giving me expected results.. Am I missing something? 
please help..

A:

You can use the Haversine formula to get the great-circle distance (along a sphere) between two points.  There's some problems about treating the earth like a sphere for great distances, but for 500 meters, you're probably fine (assuming that you're not trying to drop medical packages on a boat or something).
from math import radians, sin, cos, asin, sqrt

def haversine(lat1, long1, lat2, long2, EARTH_RADIUS_KM=6372.8):

    # get distance between the points
    phi_Lat = radians(lat2 - lat1)
    phi_Long = radians(long2 - long1)

    lat1 = radians(lat1)
    lat2 = radians(lat2)

    a = sin(phi_Lat/2)**2 + \
        cos(lat1) * cos(lat2) * \
        sin(phi_Long/2)**2

    c = 2 * asin(sqrt(a))
    return EARTH_RADIUS_KM * c

if the distance between the two points is less than your threshold, it's within the range:
points_1 = (19.114315,72.911174)
points_2 = (19.112398,72.912743)
threshold_km = 0.5

distance_km = haversine(points_1[0], points_1[1], points_2[0], points_2[1])
if distance_km < threshold_km:
    print('within range')
else:
    print('outside range')

