# How to get longitude and latitude?

151 views (last 30 days)
Ara on 27 May 2024 at 6:22
Commented: Ara on 29 May 2024 at 5:52
Dear All,
I want to calculate longtitude and latitude for total electron content (TEC) using GNSS radio occulttaion (RO) data. I have the X-GPS, Y-GPS, and Z-GPS as well as X-LEO, Y-LEO, and Z-LEO. How can I calculate it in Matlab?

Manikanta Aditya on 27 May 2024 at 6:40
Hi @Ara
To calculate the longitude and latitude from the given GNSS (Global Navigation Satellite System) radio occultation data, you can transform the coordinates from the Earth-Centered, Earth-Fixed (ECEF) coordinate system to the Geodetic coordinate system (latitude, longitude, and altitude).
Here’s a simple example of how you might do this:
function [lat, lon, alt] = ecef2lla_custom(x, y, z)
% Constants for the WGS-84 ellipsoid
a = 6378137.0; % semi-major axis in meters
f = 1/298.257223563; % flattening
e2 = f * (2-f); % square of eccentricity
% Calculations
lon = atan2(y, x);
p = sqrt(x.^2 + y.^2);
theta = atan2(z * a, p * (1 - f) * a);
lat = atan2(z + e2 * (1 - f)^2 * sin(theta).^3 * a, p - e2 * cos(theta).^3 * a);
N = a ./ sqrt(1 - e2 * sin(lat).^2);
alt = p ./ cos(lat) - N;
% Convert to degrees
end
% Example coordinates
X_GPS = 1123456.7;
Y_GPS = 2123456.7;
Z_GPS = 3123456.7;
X_LEO = 2123456.7;
Y_LEO = 3123456.7;
Z_LEO = 4123456.7;
% Call the custom function to convert GNSS ECEF coordinates to geodetic coordinates
[lat_GPS, lon_GPS, alt_GPS] = ecef2lla_custom(X_GPS, Y_GPS, Z_GPS);
% Call the custom function to convert LEO ECEF coordinates to geodetic coordinates
[lat_LEO, lon_LEO, alt_LEO] = ecef2lla_custom(X_LEO, Y_LEO, Z_LEO);
% Display the results for GPS
fprintf('GPS Coordinates:\n');
GPS Coordinates:
fprintf('Latitude: %.6f degrees\n', lat_GPS);
Latitude: 52.733047 degrees
fprintf('Longitude: %.6f degrees\n', lon_GPS);
Longitude: 62.118037 degrees
fprintf('Altitude: %.2f meters\n', alt_GPS);
Altitude: -2424368.20 meters
% Display the results for LEO
fprintf('\nLEO Coordinates:\n');
LEO Coordinates:
fprintf('Latitude: %.6f degrees\n', lat_LEO);
Latitude: 47.728614 degrees
fprintf('Longitude: %.6f degrees\n', lon_LEO);
Longitude: 55.790493 degrees
fprintf('Altitude: %.2f meters\n', alt_LEO);
Altitude: -774830.00 meters
I hope this helps!
Ara on 28 May 2024 at 11:17
Thank you very much for your great explanations.
I asked ChatGPT and it mentioned "Typical DCB values for GNSS RO satellites and receivers are in the range of 1 to 20 nanoseconds, depending on the specific frequencies and systems involved. " I got 10nanosecond for satellite and 5 nanosecond for receivers. And then change it to TECU and it gives me this range. Does it sound correct to you? In one day we should have more points not only a point. Do you have any idea to get the desirable figures? The contour plot is not working? It mentioned X should be scalar but how we can do it?
satelliteDCB = 61.73; % DCB for the satellite in TECU
Ara on 29 May 2024 at 5:52
You helped me alot.
All the best,
Ara