0
$\begingroup$

I want to implement a code, where I get a user's latitude and longitude, and I will position it on a x, y, z cartezian plane, where (0,0,0) is the center of the earth.

My order of magnitude will be in millimeters, but if it is possible to leave it and a variable format, it will help a lot too.

I thought of something like:

Lo = longitude and La = latitude
So:
x = rcos (La) cos (Lo)
y = rcos (La) sin (Lo)
z = rsin (La)

can someone tell me if this is right? and how do I have these rapids in order of magnitude of millimeters?

$\endgroup$
1

1 Answer 1

1
$\begingroup$

The formulae you used here are assuming that the Earth is a sphere. Keep in mind that your Earth-centered x,y,z values can be as much as 20 km off the real values with this approximation.

Those Earth-centered x,y,z coordinates also depend on the elevation of your points. So if you do not have that information, you won't be able to compute the exact coordinates, let alone with millimeter accuracy. Moreover, precision and accuracy aren't the same thing, you could calculate and express values with millimeter precision, but if the accuracy of your points is only, say, a few meters, then that kind of precision is overkill. To put that in context, millimeter accuracy is used mainly in geodesy and seismology, but for more general applications, perhaps you're not dealing with those accuracies, and don't need that much precision in your final values. A general rule of thumb is to express your values with a precision no more than 1 order of magnitude smaller than your accuracy, otherwise, it could be misleading.

If you are willing to assume that the Earth is an ellipsoid of revolution, you can use the following formulae:

$$X = \left(N\left(\phi\right)+h\right)\text{cos }\phi\text{ cos }\lambda$$ $$Y = \left(N\left(\phi\right)+h\right)\text{cos }\phi\text{ sin }\lambda$$ $$Z = \left(\frac{b^2}{a^2}N\left(\phi\right)+h\right)\text{ sin }\phi$$ $$\text{Where:}$$ $$N\left(\phi\right)=\frac{a}{\sqrt{1-e^2\text{ sin}^2\phi}}$$ $$e^2=1-\frac{b^2}{a^2}$$ $$a=6378137\text{ m (in WGS84)}$$ $$b=6356752.314\text{ m (in WGS84)}$$ ($\phi, \lambda, h$ are respectively latitudes, longitudes and ellipsoidal heights)

The ellipsoid is within about 100 meters from the geoid (essentially mean sea level), so it is a better approximation that the sphere. To get the best accuracy, you would need to add the geoid height at each of your points to get actual ellipsoidal heights, and use that in the formulae. This would ensure accuracy and consistency across the whole globe, but if you are mainly concerned with relative accuracy in a specific region, then you may not have to consider this.

$\endgroup$
1
  • $\begingroup$ Thanks, yes I consider my height from sea level, and latitude and longitude my position in the earth's crust $\endgroup$ Nov 10, 2020 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.