Changeset 15126


Ignore:
Timestamp:
05/28/13 11:55:54 (12 years ago)
Author:
adhikari
Message:

CHG: xy2lambert function is added for reverse calculation of lambert2xy

Location:
issm/trunk-jpl/src/m/lambert
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/lambert/lambert2xy.m

    r15106 r15126  
    1 function [x,y] = lambert2xy(lat,lon,projection_center_lat,projection_center_lon) 
     1function [x,y] = lambert2xy(lat,lon,sgn,projection_center_lat,projection_center_lon) 
    22%LAMBERT2XY - converts lat long from Lambert Azimuthal to Polar Stereographic
    33%
     
    77%
    88%   Usage:
    9 %      [x,y] = ll2xy(lat,lon)
    10 %      [x,y] = ll2xy(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)
    1111%
    1212%      - 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]
     13
     14%      - sgn = +1 N hemisphere [default projection center lat = 90 lon=0]
     15%              -1 S hemisphere [default projection center lat = -90 lon=0]
    1616
    1717%Get projection_center_lat and projection_center_lon
    18 if nargin==4,
     18if nargin==5,
    1919        latitude0  = projection_center_lat;
    2020        longitude0 = projection_center_lon;
    21 elseif nargin==2,
    22         if lat>0,
     21elseif nargin==3,
     22        if sgn==1,
    2323                latitude0 = 90; longitude0 = 0;
    2424                disp('Info: creating coordinates in polar stereographic (Projection center lat: 90N lon: 0)');
    25         elseif lat<0,
     25        elseif sgn==-1,
    2626                latitude0 = -90; longitude0 = 0;
    2727                disp('Info: creating coordinates in polar stereographic (Projection center lat: 90S lon: 0)');
     28        else
     29                error('Sign should be either +1 or -1');
    2830        end
    2931else
     
    5860
    5961% 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);
     62if(abs(lat)==90)
     63        x=0.0;
     64        y=0.0;
    6865else
    6966        x=(B*D)*(cos(b)*sin(lam-lam0));
    7067        y=(B/D)*((cos(b0)*sin(b))-(sin(b0)*cos(b)*cos(lam-lam0)));
    7168end
     69
Note: See TracChangeset for help on using the changeset viewer.