V
V
vQFd42016-10-05 14:16:40
Python
vQFd4, 2016-10-05 14:16:40

How to form a neighborhood of a given metric radius around a geographically given center in python?

Actually, the problem is quite simple: to form a neighborhood of a radius given in kilometers around a point given by geographic coordinates. That is, I want to have a function that receives the center of the circle as input in the form of longitude and latitude coordinates, radius, and at the output gives a coordinate from this epsilon neighborhood, randomly selected according to the normal law or evenly distributed points inside the circle. Surely this is already available in python in one form or another, but since this ecosystem is extremely new for me, I could not immediately find something simple and convenient. Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vQFd4, 2016-10-05
@vQFd4

freeExec no, I didn’t forget)) only then it’s not a circle, but a spherical segment)) why this is important, you can find out, for example, from Vladimir Arnold’s book for children from 5 to 15))
But even if we assume that the distortions of the sweep are not important to us and we will use the circle as the locus of points removed at a given distance. That all the same there are certain problems with construction of distribution on this remarkable geometrical figure. If everything is still more or less simple for a uniform distribution, in order to set a uniform distribution it is enough just to go to polar coordinates and use uniformly distributed samples for the angle and radius, then for a normal distribution such a focus will no longer work, that is, a normally distributed sample of the angle of rotation and radius will not give me a two-dimensional normal distribution on the plane inside the circle in Cartesian coordinates at all, so I have to come up with something more clever.
And about the original question. I'm not suggesting you draw me a solution. This, I think, is quite a typical task, and I'm sure that there is almost certainly some python module that solves it. And since I started using Python quite recently, a couple of weeks ago, I unfortunately do not know what to choose. There are many modules for working with geodata, but so far I have not found the functionality I need in them, unfortunately. And I will be extremely grateful to you if you poke me into some module where it is.

F
freeExec, 2016-10-05
@freeExec

And what exactly is the difficulty? Forgot the circle formula? Add to it the scale factors of the selected coordinate system to convert degrees to meters.

S
Sergey Pankov, 2016-10-06
@trapwalker

What do you mean by "normal distribution in a neighborhood of radius..."? The normal distribution is given by the mat-expectation (this is our center) and the variance. This does not mean that our random variable (point) will not go beyond this circle of yours, if by its radius you mean dispersion.
And if not, do I understand correctly that your task can be reformulated as follows:
Get a random point on the geoid with a given expectation and variance, which (point) lies in a given radius. That is, take random points according to a given distribution law until you meet one that is inside the circle?
The circle in the context of a normal distribution is confusing.
It has not yet been described what to do at large radii. If we are talking only about small radii, then you can work with a projection, for example, a meraktor and with Cartesian coordinates, as you yourself said.
If it's important, then you were right about polar coordinates. With a uniform distribution, we select the azimuth of a point from a given center, and with a normal distribution, the modulo distance and look for formulas that will add a vector given by polar coordinates to a geo-point.
Python has nothing to do with it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question