I got a point with latitude and longitude using decimals. The point is centered in a circle, the radius of the circle is x km. How do I find the all latitudes and longitudes which covers in the circle?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Probably the easiest answer is using pythagoras.
You got a point (x,y) which is the center of a circle of radius r.
‘How do I find the all latitudes and longitudes which covers in the circle?’ is almost infinite.
Instead you would rather want to check if a center point is within the radius of a circle (guessing you want to figure out what locations are within k km of point (x,y)).
Given point (x1,y1), you would do sqrt((x1-x)^2 + (y1-y)^2) (pythagoras theorem a^2 = b^2 + c^2) to find the distance from point (x,y) to point(x1,y1) and check if the distance is <= to radius r. Bounds are easily calculated (xmin = x-r, xmax = x+r etc.).
In terms of actual distance, you would probably need to use the Haversine formula:
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1−a))
d = R.c
where R is earth’s radius (mean radius = 6,371km) (d is distance);
note that angles need to be in radians to pass to trig functions!
More on that here http://www.movable-type.co.uk/scripts/latlong.html