source:
issm/oecreview/Archive/14312-15392/ISSM-15125-15126.diff
Last change on this file was 15393, checked in by , 12 years ago | |
---|---|
File size: 5.0 KB |
-
../trunk-jpl/src/m/lambert/lambert2xy.m
1 function [x,y] = lambert2xy(lat,lon, projection_center_lat,projection_center_lon)1 function [x,y] = lambert2xy(lat,lon,sgn,projection_center_lat,projection_center_lon) 2 2 %LAMBERT2XY - converts lat long from Lambert Azimuthal to Polar Stereographic 3 3 % 4 4 % Converts from geodetic latitude and longitude that are … … 6 6 % Stereographic (X,Y) coordinates for the polar regions. 7 7 % 8 8 % Usage: 9 % [x,y] = l l2xy(lat,lon)10 % [x,y] = l l2xy(lat,lon,projection_center_lat,projection_center_lon)9 % [x,y] = lambert2xy(lat,lon,sgn) 10 % [x,y] = lambert2xy(lat,lon,sgn,projection_center_lat,projection_center_lon) 11 11 % 12 12 % - provide lat in [-90,90] and lon in [-180,180]. 13 %14 % - default: North hemisphere [projection center lat = 90 lon=0]15 % South hemisphere [projection center lat = -90 lon=0]16 13 14 % - sgn = +1 N hemisphere [default projection center lat = 90 lon=0] 15 % -1 S hemisphere [default projection center lat = -90 lon=0] 16 17 17 %Get projection_center_lat and projection_center_lon 18 if nargin== 4,18 if nargin==5, 19 19 latitude0 = projection_center_lat; 20 20 longitude0 = projection_center_lon; 21 elseif nargin== 2,22 if lat>0,21 elseif nargin==3, 22 if sgn==1, 23 23 latitude0 = 90; longitude0 = 0; 24 24 disp('Info: creating coordinates in polar stereographic (Projection center lat: 90N lon: 0)'); 25 elseif lat<0,25 elseif sgn==-1, 26 26 latitude0 = -90; longitude0 = 0; 27 27 disp('Info: creating coordinates in polar stereographic (Projection center lat: 90S lon: 0)'); 28 else 29 error('Sign should be either +1 or -1'); 28 30 end 29 31 else 30 32 help lambert2xy … … 57 59 B =Rq*sqrt(2/(1+sin(b0)*sin(b)+(cos(b0)*cos(b)*cos(lam-lam0)))); 58 60 59 61 % Calculation of x and y 60 if(lat==90) 61 rho=a*sqrt(qp-q); 62 x=rho*sin(lam-lam0); 63 y=-rho*cos(lam-lam0); 64 elseif(lat==-90) 65 rho=a*sqrt(qp+q); 66 x=rho*sin(lam-lam0); 67 y=rho*cos(lam-lam0); 62 if(abs(lat)==90) 63 x=0.0; 64 y=0.0; 68 65 else 69 66 x=(B*D)*(cos(b)*sin(lam-lam0)); 70 67 y=(B/D)*((cos(b0)*sin(b))-(sin(b0)*cos(b)*cos(lam-lam0))); 71 68 end 69 -
../trunk-jpl/src/m/lambert/xy2lambert.m
1 function [lat,lon] = xy2lambert(x,y,sgn,projection_center_lat,projection_center_lon) 2 %XY2LAMBERT - converts xy to lat lon in Lambert Azimuthal 3 % 4 % Converts from Ploar Stereographic (X,Y) coordinates to geodetic 5 % lat lon that are in Lambert Azimuthal (equal area) projection. 6 % 7 % Usage: 8 % [lat,lon] = xy2lambert(x,y,sgn) 9 % [lat,lon] = xy2lambert(x,y,sgn,projection_center_lat,projection_center_lon) 10 % 11 % - provide lat in [-90,90] and lon in [-180,180]. 12 % 13 % - sgn = +1 N hemisphere [default projection center lat = 90 lon=0] 14 % -1 S hemisphere [default projection center lat = -90 lon=0] 15 16 %Get projection_center_lat and projection_center_lon 17 if nargin==5, 18 latitude0 = projection_center_lat; 19 longitude0 = projection_center_lon; 20 elseif nargin==3, 21 if sgn==1, 22 latitude0 = 90; longitude0 = 0; 23 disp('Info: creating coordinates in Lambert Azimuthal equal-area (Projection center lat: 90N lon: 0)'); 24 elseif sgn==-1, 25 latitude0 = -90; longitude0 = 0; 26 disp('Info: creating coordinates in Lambert Azimuthal equal-area (Projection center lat: 90S lon: 0)'); 27 else 28 error('Sign should be either +1 or -1'); 29 end 30 else 31 help xy2lambert 32 error('bad usage'); 33 end 34 35 % Radius of the earth in meters 36 a = 6378137.0; 37 % Eccentricity of the Hughes ellipsoid squared 38 e = 0.081819191; 39 40 % Projection center latitude and longitude in radians 41 phi0 = latitude0 * pi/180; 42 lam0 = longitude0 * pi/180; 43 44 % Some constants based on phi0 and lam0 45 % (as in forward calculation) 46 qp= (1-e^2)*((1/(1-e^2))-((1/(2*e))*log((1-e)/(1+e)))); 47 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))))); 48 Rq=a*sqrt(qp/2); 49 b0=asin(q0/qp); 50 D =a*(cos(phi0)/sqrt(1-e^2*sin(phi0)*sin(phi0)))/(Rq*cos(b0)); 51 52 % Some other (x,y) dependent parameters 53 rho=sqrt((x/D)^2+(D*y)^2); 54 C=2*asin(rho/(2*Rq)); 55 b_prime=asin((cos(C)*sin(b0))+((D*y*sin(C)*cos(b0))/rho)); 56 57 % Calculation of lat and lon 58 dist=sqrt(x^2+y^2); 59 if(dist<=0.1) 60 lat=sgn*90.0; 61 lon=0.0; 62 else 63 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)); 64 lon_rad=lam0+atan(x*sin(C)/(D*rho*cos(b0)*cos(C)-D^2*y*sin(b0)*sin(C))); 65 % in degrees 66 lat=lat_rad*180/pi; 67 lon=lon_rad*180/pi; 68 end 69
Note:
See TracBrowser
for help on using the repository browser.