I need count random lat and lon in radius 10 and 20 kilometres from center, which cords i have.
For example:
location_center = {
"lat": 5.0123,
"lon": 40.712
}
Random cords in radius 10 km:
location_center = {
"lat": 6.246,
"lon": 45.678
}
Random cords in radius 20 km:
location_center = {
"lat": 7.368,
"lon": 50.678
}
How i can count it?
Will be grateful for the help.
Generate random angle in range 0..2*Pi
Using Destination point given distance and bearing from start point
section from this page, calculate point at needed distance d
in km (with earth radius R=6378.13 km
)
brng = random() * 2 * Math.pi
lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) );
lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1),
Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));