Changeset 6341


Ignore:
Timestamp:
10/19/10 11:12:16 (14 years ago)
Author:
Mathieu Morlighem
Message:

Fixed projection routines thanks to Michael

Location:
issm/trunk/src/m/utils/LatLong
Files:
1 added
4 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/utils/LatLong/ll2xy.m

    r3259 r6341  
    1 function [x,y]=ll2xy(lat,lon);
    2 %LL2XY - convert latitude and longitude coordinates to x and y
     1function [x,y] = ll2xy(lat,lon,sgn) 
     2%LL2XY - converts lat long to polar stereographic
     3%
     4%   Converts from geodetic latitude and longitude to Polar
     5%   Stereographic (X,Y) coordinates for the polar regions.
     6%   Author: Michael P. Schodlok, December 2003 (map2ll)
    37%
    48%   Usage:
    5 %      [x,y]=ll2xy(lat,lon)
    6 %
    7 %   See also MAPLL, MAPXY
     9%      [x,y] = map2ll(lat,lon,sgn)
     10%      - sgn = Sign of latitude +1 : north latitude
     11%                               -1 : south latitude
    812
    9 lon=lon+360; % to have 0<lon<360
     13if nargin ~= 3
     14        help map2ll
     15        error('bad usage');
     16end
    1017
    11 re = 6378137.0;         % WGS84
    12 e2 = 0.00669437999015;  % WGS84
    13 sn=-1.0;        % because it's southern hemisphere
     18% Conversion constant from degrees to radians
     19cde  = 57.29577951;
     20% Standard latitude for the SSM/I grid with no distorsion
     21slat = 70.;
     22% Radius of the earth in meters
     23re   = 6378.273*10^3;
     24% Eccentricity of the Hughes ellipsoid squared
     25ex2   = .006693883;
     26% Eccentricity of the Hughes ellipsoid
     27ex    =  sqrt(ex2);
    1428
    15 a=re;
    16 e=sqrt(e2);
     29if sgn == 1
     30        delta = 45.;
     31else
     32        delta = 0.0;
     33end
    1734
    18 phi  = sn*lat*pi/180;
    19 lambda  = lon*pi/180;
     35latitude  = abs(lat) * pi/180.;
     36longitude = (lon + delta) * pi/180.;
    2037
    21 qp = 1 - (1-e2)/2/e*log((1-e)/(1+e));
    22 %m=cos(phi)/sqrt(1-e2.*sin(phi)*sin(phi));
    23 q=(1-e2)*(sin(phi)./(1-e2*sin(phi).^2)-0.5/e*log((1-e*sin(phi))./(1+e*sin(phi))));
    24 rho = a*sqrt(qp-q);
    25 x = rho.*sin(lambda);
    26 y = - sn*rho.*cos(lambda);
     38% compute X and Y in grid coordinates.
     39T = tan(pi/4-latitude/2) ./ ((1-ex*sin(latitude))./(1+ex*sin(latitude))).^(ex/2);
    2740
     41if (90 - slat) <  1.e-5
     42        rho = 2.*re*T/sqrt((1.+ex)^(1.+ex)*(1.-ex)^(1.-ex));
     43else
     44        sl  = slat*pi/180.;
     45        tc  = tan(pi/4.-sl/2.)/((1.-ex*sin(sl))/(1.+ex*sin(sl)))^(ex/2.);
     46        mc  = cos(sl)/sqrt(1.0-ex2*(sin(sl)^2));
     47        rho = re*mc*T/tc;
     48end
    2849
    29 %lon=lon-360; % to recover the initial longitude
     50y = -rho .* sgn .* cos(sgn.*longitude);
     51x =  rho .* sgn .* sin(sgn.*longitude);
    3052
     53[cnt1,cnt2] = find(latitude >= pi / 2.);
     54
     55if cnt1
     56        x(cnt1,1) = 0.0
     57        y(cnt1,1) = 0.0
     58end
  • issm/trunk/src/m/utils/LatLong/utm2ll.m

    r1227 r6341  
    5050end
    5151
    52 
    53 
    5452% Memory pre-allocation
    5553%
    5654Lat=zeros(n1,1);
    5755Lon=zeros(n1,1);
    58 
    5956
    6057% Main Loop
     
    119116
    120117end
    121 
Note: See TracChangeset for help on using the changeset viewer.