Reputation: 1766
I have a central lat, long point along with radius of 1 km. I want to fetch all the lat, long points inside 1 km.
From the output list, I want to compare values with another lat, long value to check whether it is matching or not?
For example, If I have a point that is (51.42337159689999, -0.562302811958012). I want to fetch all the points in 1 km radius.
Which is the better way to do this? Can anyone help me with this?
Upvotes: 0
Views: 2653
Reputation: 205
Here's my rough attempt... Hopefully this helps getting your brain flowing?
import math
def findpoints(lon, lat):
radius = 1
N = 360
# generate points
circlePoints = []
for k in range(N):
angle = math.pi*2*k/N
dx = radius*math.cos(angle)
dy = radius*math.sin(angle)
point = {}
point['lat']= lat + (180/math.pi)*(dy/6371) #Earth Radius
point['lon']= lon + (180/math.pi)*(dx/6371)/math.cos(lon*math.pi/180) #Earth Radius
# add to list
circlePoints.append(point)
return circlePoints
Upvotes: 7