![]() Re: Conversion between ECEF to local Geodetics dat...
| David L. Wilson | 04-21-2009 |
If you were Registered and logged in, you could reply and use other advanced thread options
Could anybody please provide me a link or material to convert from ECEF to
local Geodetics datum (like East-North-Sky)? Better with plots. Any other
paper about datum conversion are also welcome.
Thank you!
You might want to look at
http://www.ngs.noaa.gov/PC_PROD/XYZWIN/
Johnson L wrote:
> Could anybody please provide me a link or material to convert from ECEF to
> local Geodetics datum (like East-North-Sky)? Better with plots. Any other
> paper about datum conversion are also welcome. Thank you!
> local Geodetics datum (like East-North-Sky)? Better with plots. Any other
> paper about datum conversion are also welcome. Thank you!
KBH wrote:
Here is some KBH code...just straight out of my files...for Delphi console
mode. And so the code will convert ECEF XYZ coordinates in meters to
latitude and longitude. Then the latitude and longitude can be
converted...with other programs...to UTM or to State Plane or to Local
Topocentric. (And I might have some Local Topocentric code but I don't post
my UTM code.)
Var
a: string;
Procedure Latlon;
Var
ra, lat, lon, x, y, z: double;
a, ee, v, h: double;
nr, ea, ht: double;
Begin
{KBH Code}
ra:= 180 / Pi;
a:= 6378137;
ee:= 0.006694379990;
WriteLn;
Write(' Input latitude in degrees: ');
ReadLn(lat);
Write(' Input longitude in degrees: ');
ReadLn(lon);
Write(' Input ellipsoidal height in meters: ');
ReadLn(h);
lat:= lat / ra;
lon:= lon / ra;
v:= a / Sqrt(1 - (ee * Sqr(Sin(lat))));
x:= (v + h) * Cos(lat) * Cos(lon);
y:= (v + h) * Cos(lat) * Sin(lon);
z:= ((1 - ee) * v + h) * Sin(lat);
WriteLn;
WriteLn(' x coordinate y coordinate z coordinate');
WriteLn;
WriteLn(x:18:3, y:18:3, z:18:3);
WriteLn;
{xyz to topocentric:}
{lat:= 45 / ra;
lon:= 0 / ra;}
lat:= 0;
lon:= 0;
nr:= (-x * Sin(lat) * Cos(lon)) + (-y * Sin(lat) * Sin(lon)) + (z *
Cos(lat));
ea:= (-x * Sin(lon)) + (y * Cos(lon));
ht:= (x * Cos(lat) * Cos(lon)) + (y * Cos(lat) * Sin(lon)) + (z * Sin(lat));
WriteLn(nr:18:3, ea:18:3, ht:18:3);
WriteLn;
End;
Procedure Xyzs;
Var
r, ra, lat, lon, x, y, z: double;
a, ee, f, p, u, la, lt, ha, hb, h, fm: double;
Begin
{KBH Code}
ra:= 180 / Pi;
a:= 6378137;
f:= 0.003352811;
fm:= 1 - f;
ee:= 0.006694379990;
WriteLn;
Write(' Input x coordinate in meters: ');
ReadLn(x);
Write(' Input y coordinate in meters: ');
ReadLn(y);
Write(' Input z coordinate in meters: ');
ReadLn(z);
If (x = 0) Then x:= 0.0001;
{If (x > a) Or (y > a) Then Exit;
If (x < -a) Or (y < -a) Then Exit;}
p:= Sqrt(Sqr(x) + Sqr(y));
r:= Sqrt(Sqr(p) + Sqr(z));
u:= z / p * (fm + (ee * a / r));
u:= ArcTan(u);
lon:= ArcTan(y / x);
la:= (z * fm) + (ee * a * Sin(u) * Sqr(Sin(u)));
lt:= fm * (p - (ee * a * Cos(u) * Sqr(Cos(u))));
lat:= ArcTan(la / lt);
ha:= p * Cos(lat) + (z * Sin(lat));
hb:= a * Sqrt(1 - (ee * Sqr(Sin(lat))));
h:= ha - hb;
lon:= lon * ra;
lat:= lat * ra;
If (x < 0) Then lon:= 180 + lon;
If (lon > 180) Then lon:= lon - 360;
WriteLn;
WriteLn(' Latitude Longitude');
WriteLn;
WriteLn(lat:18:6, lon:18:6, h:18:3);
WriteLn;
End;
Begin
{KBH Code}
WriteLn;
a:= 'lat';
While (a = 'lat') Or (a = 'xyz') Do
Begin
Write(' Enter "lat" for lat/lon to xyz or enter "xyz" for xyz to lat/lon:
');
ReadLn(a);
If (a <> 'lat') And (a <> 'xyz') Then
Begin
WriteLn;
WriteLn(' Program end: Hit [Enter]');
End;
If (a = 'lat') Then Latlon;
If (a = 'xyz') Then Xyzs;
End;
ReadLn;
End.
And those are ellipsoidal conversions...
I did a google search for my Local Topocentric code and found it at
sci.tech-archive.net:
{Latitude and longitude to ECEF xyz}
{KBH Code}
ra:= 180 / Pi;
a:= 6378137;
ee:= 0.006694379990;
Write(' Input latitude in degrees: ');
ReadLn(lat);
Write(' Input longitude in degrees: ');
ReadLn(lon);
Write(' Input ellipsoidal height in meters: ');
ReadLn(h);
lat:= lat / ra;
lon:= lon / ra;
v:= a / Sqrt(1 - (ee * Sqr(Sin(lat))));
x:= (v + h) * Cos(lat) * Cos(lon);
y:= (v + h) * Cos(lat) * Sin(lon);
z:= ((1 - ee) * v + h) * Sin(lat);
----------------------------------------------------
{ECEF xyz to local topocentric}
{KBH Code}
nr:= (-x * Sin(lat) * Cos(lon)) + (-y * Sin(lat) * Sin(lon)) + (z *
Cos(lat));
ea:= (-x * Sin(lon)) + (y * Cos(lon));
ht:= (x * Cos(lat) * Cos(lon)) + (y * Cos(lat) * Sin(lon)) + (z * Sin(lat));
{Note the first input is the lat and lon of the first xyz point converted to
local topocentric and then that lat and lon is held in the computations for
all the next xyz input points going to the same local topocentric system}
-----------------------------------------------------
{ECEF xyz to latitude and longitude}
{KBH Code}
ra:= 180 / Pi;
a:= 6378137;
f:= 0.003352811;
fm:= 1 - f;
ee:= 0.006694379990;
WriteLn;
Write(' Input x coordinate in meters: ');
ReadLn(x);
Write(' Input y coordinate in meters: ');
ReadLn(y);
Write(' Input z coordinate in meters: ');
ReadLn(z);
If (x = 0) Then x:= 0.0001;
{If (x > a) Or (y > a) Then Exit;
If (x < -a) Or (y < -a) Then Exit;}
p:= Sqrt(Sqr(x) + Sqr(y));
r:= Sqrt(Sqr(p) + Sqr(z));
u:= z / p * (fm + (ee * a / r));
u:= ArcTan(u);
lon:= ArcTan(y / x);
la:= (z * fm) + (ee * a * Sin(u) * Sqr(Sin(u)));
lt:= fm * (p - (ee * a * Cos(u) * Sqr(Cos(u))));
lat:= ArcTan(la / lt);
ha:= p * Cos(lat) + (z * Sin(lat));
hb:= a * Sqrt(1 - (ee * Sqr(Sin(lat))));
h:= ha - hb;
lon:= lon * ra;
lat:= lat * ra;
If (x < 0) Then lon:= 180 + lon;
If (lon > 180) Then lon:= lon - 360;
------------------------------------------------------
>I did a google search for my Local Topocentric code and found it at
>sci.tech-archive.net:
> {Latitude and longitude to ECEF xyz}
> {KBH Code}
> ra:= 180 / Pi;
> a:= 6378137;
> ee:= 0.006694379990;
> Write(' Input latitude in degrees: ');
> ReadLn(lat);
> Write(' Input longitude in degrees: ');
> ReadLn(lon);
> Write(' Input ellipsoidal height in meters: ');
> ReadLn(h);
> lat:= lat / ra;
> lon:= lon / ra;
> v:= a / Sqrt(1 - (ee * Sqr(Sin(lat))));
> x:= (v + h) * Cos(lat) * Cos(lon);
> y:= (v + h) * Cos(lat) * Sin(lon);
> z:= ((1 - ee) * v + h) * Sin(lat);
> ----------------------------------------------------
> {ECEF xyz to local topocentric}
> {KBH Code}
> nr:= (-x * Sin(lat) * Cos(lon)) + (-y * Sin(lat) * Sin(lon)) + (z *
> Cos(lat));
> ea:= (-x * Sin(lon)) + (y * Cos(lon));
> ht:= (x * Cos(lat) * Cos(lon)) + (y * Cos(lat) * Sin(lon)) + (z *
> Sin(lat));
> {Note the first input is the lat and lon of the first xyz point converted
> to local topocentric and then that lat and lon is held in the computations
> for all the next xyz input points going to the same local topocentric
> system}
> -----------------------------------------------------
> {ECEF xyz to latitude and longitude}
> {KBH Code}
> ra:= 180 / Pi;
> a:= 6378137;
> f:= 0.003352811;
> fm:= 1 - f;
> ee:= 0.006694379990;
> WriteLn;
> Write(' Input x coordinate in meters: ');
> ReadLn(x);
> Write(' Input y coordinate in meters: ');
> ReadLn(y);
> Write(' Input z coordinate in meters: ');
> ReadLn(z);
> If (x = 0) Then x:= 0.0001;
> {If (x > a) Or (y > a) Then Exit;
> If (x < -a) Or (y < -a) Then Exit;}
> p:= Sqrt(Sqr(x) + Sqr(y));
> r:= Sqrt(Sqr(p) + Sqr(z));
> u:= z / p * (fm + (ee * a / r));
> u:= ArcTan(u);
> lon:= ArcTan(y / x);
> la:= (z * fm) + (ee * a * Sin(u) * Sqr(Sin(u)));
> lt:= fm * (p - (ee * a * Cos(u) * Sqr(Cos(u))));
> lat:= ArcTan(la / lt);
> ha:= p * Cos(lat) + (z * Sin(lat));
> hb:= a * Sqrt(1 - (ee * Sqr(Sin(lat))));
> h:= ha - hb;
> lon:= lon * ra;
> lat:= lat * ra;
> If (x < 0) Then lon:= 180 + lon;
> If (lon > 180) Then lon:= lon - 360;
> ------------------------------------------------------
>sci.tech-archive.net:
> {Latitude and longitude to ECEF xyz}
> {KBH Code}
> ra:= 180 / Pi;
> a:= 6378137;
> ee:= 0.006694379990;
> Write(' Input latitude in degrees: ');
> ReadLn(lat);
> Write(' Input longitude in degrees: ');
> ReadLn(lon);
> Write(' Input ellipsoidal height in meters: ');
> ReadLn(h);
> lat:= lat / ra;
> lon:= lon / ra;
> v:= a / Sqrt(1 - (ee * Sqr(Sin(lat))));
> x:= (v + h) * Cos(lat) * Cos(lon);
> y:= (v + h) * Cos(lat) * Sin(lon);
> z:= ((1 - ee) * v + h) * Sin(lat);
> ----------------------------------------------------
> {ECEF xyz to local topocentric}
> {KBH Code}
> nr:= (-x * Sin(lat) * Cos(lon)) + (-y * Sin(lat) * Sin(lon)) + (z *
> Cos(lat));
> ea:= (-x * Sin(lon)) + (y * Cos(lon));
> ht:= (x * Cos(lat) * Cos(lon)) + (y * Cos(lat) * Sin(lon)) + (z *
> Sin(lat));
> {Note the first input is the lat and lon of the first xyz point converted
> to local topocentric and then that lat and lon is held in the computations
> for all the next xyz input points going to the same local topocentric
> system}
> -----------------------------------------------------
> {ECEF xyz to latitude and longitude}
> {KBH Code}
> ra:= 180 / Pi;
> a:= 6378137;
> f:= 0.003352811;
> fm:= 1 - f;
> ee:= 0.006694379990;
> WriteLn;
> Write(' Input x coordinate in meters: ');
> ReadLn(x);
> Write(' Input y coordinate in meters: ');
> ReadLn(y);
> Write(' Input z coordinate in meters: ');
> ReadLn(z);
> If (x = 0) Then x:= 0.0001;
> {If (x > a) Or (y > a) Then Exit;
> If (x < -a) Or (y < -a) Then Exit;}
> p:= Sqrt(Sqr(x) + Sqr(y));
> r:= Sqrt(Sqr(p) + Sqr(z));
> u:= z / p * (fm + (ee * a / r));
> u:= ArcTan(u);
> lon:= ArcTan(y / x);
> la:= (z * fm) + (ee * a * Sin(u) * Sqr(Sin(u)));
> lt:= fm * (p - (ee * a * Cos(u) * Sqr(Cos(u))));
> lat:= ArcTan(la / lt);
> ha:= p * Cos(lat) + (z * Sin(lat));
> hb:= a * Sqrt(1 - (ee * Sqr(Sin(lat))));
> h:= ha - hb;
> lon:= lon * ra;
> lat:= lat * ra;
> If (x < 0) Then lon:= 180 + lon;
> If (lon > 180) Then lon:= lon - 360;
> ------------------------------------------------------
Okay...I found a source that says that Topocentric Coordinates are often
called EHN (East North Height).
- purpose of map datum?
- Satellite Navigation
- 2011-02-08
- Saving Positions with wrong Datum
- Garmin GPS
- 2011-10-12
- DeLorme file conversion
- Satellite Navigation
- 2011-03-29
- Cost of New Maps
- Tomtom GPS
- 2009-11-15
- Forerunner 205 - Bizarre Behavior
- Garmin GPS
- 2009-02-15









> local Geodetics datum (like East-North-Sky)? Better with plots. Any other
> paper about datum conversion are also welcome.
> Thank you!