[15393] | 1 | Index: ../trunk-jpl/src/m/lambert/lambert2xy.m
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/lambert/lambert2xy.m (revision 15125)
|
---|
| 4 | +++ ../trunk-jpl/src/m/lambert/lambert2xy.m (revision 15126)
|
---|
| 5 | @@ -1,4 +1,4 @@
|
---|
| 6 | -function [x,y] = lambert2xy(lat,lon,projection_center_lat,projection_center_lon)
|
---|
| 7 | +function [x,y] = lambert2xy(lat,lon,sgn,projection_center_lat,projection_center_lon)
|
---|
| 8 | %LAMBERT2XY - converts lat long from Lambert Azimuthal to Polar Stereographic
|
---|
| 9 | %
|
---|
| 10 | % Converts from geodetic latitude and longitude that are
|
---|
| 11 | @@ -6,25 +6,27 @@
|
---|
| 12 | % Stereographic (X,Y) coordinates for the polar regions.
|
---|
| 13 | %
|
---|
| 14 | % Usage:
|
---|
| 15 | -% [x,y] = ll2xy(lat,lon)
|
---|
| 16 | -% [x,y] = ll2xy(lat,lon,projection_center_lat,projection_center_lon)
|
---|
| 17 | +% [x,y] = lambert2xy(lat,lon,sgn)
|
---|
| 18 | +% [x,y] = lambert2xy(lat,lon,sgn,projection_center_lat,projection_center_lon)
|
---|
| 19 | %
|
---|
| 20 | % - provide lat in [-90,90] and lon in [-180,180].
|
---|
| 21 | -%
|
---|
| 22 | -% - default: North hemisphere [projection center lat = 90 lon=0]
|
---|
| 23 | -% South hemisphere [projection center lat = -90 lon=0]
|
---|
| 24 |
|
---|
| 25 | +% - sgn = +1 N hemisphere [default projection center lat = 90 lon=0]
|
---|
| 26 | +% -1 S hemisphere [default projection center lat = -90 lon=0]
|
---|
| 27 | +
|
---|
| 28 | %Get projection_center_lat and projection_center_lon
|
---|
| 29 | -if nargin==4,
|
---|
| 30 | +if nargin==5,
|
---|
| 31 | latitude0 = projection_center_lat;
|
---|
| 32 | longitude0 = projection_center_lon;
|
---|
| 33 | -elseif nargin==2,
|
---|
| 34 | - if lat>0,
|
---|
| 35 | +elseif nargin==3,
|
---|
| 36 | + if sgn==1,
|
---|
| 37 | latitude0 = 90; longitude0 = 0;
|
---|
| 38 | disp('Info: creating coordinates in polar stereographic (Projection center lat: 90N lon: 0)');
|
---|
| 39 | - elseif lat<0,
|
---|
| 40 | + elseif sgn==-1,
|
---|
| 41 | latitude0 = -90; longitude0 = 0;
|
---|
| 42 | disp('Info: creating coordinates in polar stereographic (Projection center lat: 90S lon: 0)');
|
---|
| 43 | + else
|
---|
| 44 | + error('Sign should be either +1 or -1');
|
---|
| 45 | end
|
---|
| 46 | else
|
---|
| 47 | help lambert2xy
|
---|
| 48 | @@ -57,15 +59,11 @@
|
---|
| 49 | B =Rq*sqrt(2/(1+sin(b0)*sin(b)+(cos(b0)*cos(b)*cos(lam-lam0))));
|
---|
| 50 |
|
---|
| 51 | % Calculation of x and y
|
---|
| 52 | -if(lat==90)
|
---|
| 53 | - rho=a*sqrt(qp-q);
|
---|
| 54 | - x=rho*sin(lam-lam0);
|
---|
| 55 | - y=-rho*cos(lam-lam0);
|
---|
| 56 | -elseif(lat==-90)
|
---|
| 57 | - rho=a*sqrt(qp+q);
|
---|
| 58 | - x=rho*sin(lam-lam0);
|
---|
| 59 | - y=rho*cos(lam-lam0);
|
---|
| 60 | +if(abs(lat)==90)
|
---|
| 61 | + x=0.0;
|
---|
| 62 | + y=0.0;
|
---|
| 63 | else
|
---|
| 64 | x=(B*D)*(cos(b)*sin(lam-lam0));
|
---|
| 65 | y=(B/D)*((cos(b0)*sin(b))-(sin(b0)*cos(b)*cos(lam-lam0)));
|
---|
| 66 | end
|
---|
| 67 | +
|
---|
| 68 | Index: ../trunk-jpl/src/m/lambert/xy2lambert.m
|
---|
| 69 | ===================================================================
|
---|
| 70 | --- ../trunk-jpl/src/m/lambert/xy2lambert.m (revision 0)
|
---|
| 71 | +++ ../trunk-jpl/src/m/lambert/xy2lambert.m (revision 15126)
|
---|
| 72 | @@ -0,0 +1,69 @@
|
---|
| 73 | +function [lat,lon] = xy2lambert(x,y,sgn,projection_center_lat,projection_center_lon)
|
---|
| 74 | +%XY2LAMBERT - converts xy to lat lon in Lambert Azimuthal
|
---|
| 75 | +%
|
---|
| 76 | +% Converts from Ploar Stereographic (X,Y) coordinates to geodetic
|
---|
| 77 | +% lat lon that are in Lambert Azimuthal (equal area) projection.
|
---|
| 78 | +%
|
---|
| 79 | +% Usage:
|
---|
| 80 | +% [lat,lon] = xy2lambert(x,y,sgn)
|
---|
| 81 | +% [lat,lon] = xy2lambert(x,y,sgn,projection_center_lat,projection_center_lon)
|
---|
| 82 | +%
|
---|
| 83 | +% - provide lat in [-90,90] and lon in [-180,180].
|
---|
| 84 | +%
|
---|
| 85 | +% - sgn = +1 N hemisphere [default projection center lat = 90 lon=0]
|
---|
| 86 | +% -1 S hemisphere [default projection center lat = -90 lon=0]
|
---|
| 87 | +
|
---|
| 88 | +%Get projection_center_lat and projection_center_lon
|
---|
| 89 | +if nargin==5,
|
---|
| 90 | + latitude0 = projection_center_lat;
|
---|
| 91 | + longitude0 = projection_center_lon;
|
---|
| 92 | +elseif nargin==3,
|
---|
| 93 | + if sgn==1,
|
---|
| 94 | + latitude0 = 90; longitude0 = 0;
|
---|
| 95 | + disp('Info: creating coordinates in Lambert Azimuthal equal-area (Projection center lat: 90N lon: 0)');
|
---|
| 96 | + elseif sgn==-1,
|
---|
| 97 | + latitude0 = -90; longitude0 = 0;
|
---|
| 98 | + disp('Info: creating coordinates in Lambert Azimuthal equal-area (Projection center lat: 90S lon: 0)');
|
---|
| 99 | + else
|
---|
| 100 | + error('Sign should be either +1 or -1');
|
---|
| 101 | + end
|
---|
| 102 | +else
|
---|
| 103 | + help xy2lambert
|
---|
| 104 | + error('bad usage');
|
---|
| 105 | +end
|
---|
| 106 | +
|
---|
| 107 | +% Radius of the earth in meters
|
---|
| 108 | +a = 6378137.0;
|
---|
| 109 | +% Eccentricity of the Hughes ellipsoid squared
|
---|
| 110 | +e = 0.081819191;
|
---|
| 111 | +
|
---|
| 112 | +% Projection center latitude and longitude in radians
|
---|
| 113 | +phi0 = latitude0 * pi/180;
|
---|
| 114 | +lam0 = longitude0 * pi/180;
|
---|
| 115 | +
|
---|
| 116 | +% Some constants based on phi0 and lam0
|
---|
| 117 | +% (as in forward calculation)
|
---|
| 118 | +qp= (1-e^2)*((1/(1-e^2))-((1/(2*e))*log((1-e)/(1+e))));
|
---|
| 119 | +q0=(1-e^2)*((sin(phi0)/(1-e^2*sin(phi0)*sin(phi0)))-((1/(2*e))*log((1-e*sin(phi0))/(1+e*sin(phi0)))));
|
---|
| 120 | +Rq=a*sqrt(qp/2);
|
---|
| 121 | +b0=asin(q0/qp);
|
---|
| 122 | +D =a*(cos(phi0)/sqrt(1-e^2*sin(phi0)*sin(phi0)))/(Rq*cos(b0));
|
---|
| 123 | +
|
---|
| 124 | +% Some other (x,y) dependent parameters
|
---|
| 125 | +rho=sqrt((x/D)^2+(D*y)^2);
|
---|
| 126 | +C=2*asin(rho/(2*Rq));
|
---|
| 127 | +b_prime=asin((cos(C)*sin(b0))+((D*y*sin(C)*cos(b0))/rho));
|
---|
| 128 | +
|
---|
| 129 | +% Calculation of lat and lon
|
---|
| 130 | +dist=sqrt(x^2+y^2);
|
---|
| 131 | +if(dist<=0.1)
|
---|
| 132 | + lat=sgn*90.0;
|
---|
| 133 | + lon=0.0;
|
---|
| 134 | +else
|
---|
| 135 | + lat_rad=b_prime+((e^2/3+31*e^4/180+517*e^6/5040)*sin(2*b_prime))+((23*e^4/360+251*e^6/3780)*sin(4*b_prime))+((761*e^6/45360)*sin(6*b_prime));
|
---|
| 136 | + lon_rad=lam0+atan(x*sin(C)/(D*rho*cos(b0)*cos(C)-D^2*y*sin(b0)*sin(C)));
|
---|
| 137 | + % in degrees
|
---|
| 138 | + lat=lat_rad*180/pi;
|
---|
| 139 | + lon=lon_rad*180/pi;
|
---|
| 140 | +end
|
---|
| 141 | +
|
---|
| 142 |
|
---|
| 143 | Property changes on: ../trunk-jpl/src/m/lambert/xy2lambert.m
|
---|
| 144 | ___________________________________________________________________
|
---|
| 145 | Added: svn:executable
|
---|
| 146 | ## -0,0 +1 ##
|
---|
| 147 | +*
|
---|
| 148 | \ No newline at end of property
|
---|