Obtain random latitude and longitude within the range of 1km without superposition

  • lng X coordinate 1000 m range factor, 0.010520
  • lat Y coordinate 1000 m range factor, 0.009000
  • 500m = 1000 m Factor divided by 2 pay attention to the precision of the coefficient, rounded
  • 2000 m = 1000 m Factor multiplied by 2
  • 3000 m = 1000 m Factor multiplied by 3
  • 5000 m = 5000 m Factor multiplied by 5

for example, the current longitude and latitude A 115.016818 and 36.532544 plus that coefficient range is a set of longitude and latitude B distance A within the range of 1000m. I want to obtain several groups of random longitude and latitude. The distance from each other is not too dense. I would like to ask you what we should do about this. It was in a random form before, but we got that several groups of longitude and latitude were too dense between each other. Want each group of longitude and latitude to differ by more than 200 meters from each other,


A relatively simple way is to first divide the determined range into n cells, and then get a point in each interval with a random number, which will be relatively sparse. Adding a padding to the interval can prevent two points from being too close to each other.


Random must have repetition, and the so-called "non-repetitive random" is actually a shuffle.


the idea I can think of is that if you need to get N sets of longitudes and latitudes, first divide the circle 1 km from the current longitude and latitude [x, y] into N parts, and then find out the central points of the N parts. and then random on these N central points.

I hope I can help you.


was in the form of random number in the wrong way. Later, it was adopted to obtain the maximum and minimum longitude and latitude first, then take the decimal part of each maximum and minimum longitude and latitude, enlarge N times random, and then reduce N times to get a set of random longitude and latitude

.
Menu