D
D
Davidaa_WoW2021-09-26 15:58:20
Geolocation
Davidaa_WoW, 2021-09-26 15:58:20

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

1 answer(s)
H
hint000, 2021-09-27
@hint000

and multiply by 6371
is 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.
The formula you found is correct in itselffor the sphere . It's called the " Five Element Formula ", and in this case, angle A = 90 degrees.
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.
Due to the fact that the Earth is slightly flattened, you will have some kind of error - instead of 600 m, you get 595 m or 605 m, but, of course, not dozens of times.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question