Answer the question
In order to leave comments, you need to log in
How to find out the distance between two points in latitude and longitude, if it is known that they are within the same city?
Need a formula to measure the distance between two points within the same city. I work on the same nocode platform, so the software solution is not suitable, like all sorts of calculators, and I don’t want to connect APIs for the sake of a solution that can be implemented inside the platform using a formula. From the data, there is the latitude and longitude of the two points.
I found this formula on the Internet so far: cos(d) = sin(φА) sin(φB) + cos(φА) cos(φB) cos(λА − λB), to calculate the distance from it we take arccos and multiply at 6371. Just trying to measure the distance between two points within the city, I got 38 kilometers, when 600 meters come out in calculators. What am I doing wrong?
Answer the question
In order to leave comments, you need to log in
and multiply by 6371is the "radius" of the earth. But it is only in kindergarten that they teach that the Earth is spherical. Already in high school, geography lessons should teach that the shape of the Earth is an ellipsoid (and in a specialized university they will explain that this is not accurate either). Those. the "radius" from the center of the earth to the pole is less than the "radius" from the center to the equator. Therefore, for practical calculations, it is impossible to get by with one constant 6371. You either have to take the parameters of the ellipsoid and calculate using more complex formulas, or use tables of meridian arc length and parallel arc length , for example, this table . Within one city, the surface can be conditionally considered flat and the distance can be calculated using the Pythagorean theorem.
I got 38 kilometers, when calculators come out 600 meters.The big error could be because you didn't convert the angles from degrees to radians . The vast majority of math function libraries consider angles in radians, unless explicitly stated otherwise.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question