Changeset 868


Ignore:
Timestamp:
Feb 11, 2005, 3:38:42 PM (20 years ago)
Author:
ole
Message:

lat-lon to UTM Done!

Location:
inundation/ga/storm_surge/pyvolution/coordinate_transforms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/coordinate_transforms/redfearn.py

    r865 r868  
    11
    22
    3 def degminsecs2decimal_degrees(dd,mm,ss):
     3def degminsec2decimal_degrees(dd,mm,ss):
    44    assert abs(mm) == mm
    55    assert abs(ss) == ss   
     
    1212    return sign * (abs(dd) + mm/60. + ss/3600.)     
    1313   
     14def decimal_degrees2degminsec(dec):
     15
     16    if dec < 0:
     17        sign = -1
     18    else:
     19        sign = 1
     20
     21    dec = abs(dec)   
     22    dd = int(dec)
     23    f = dec-dd
     24
     25    mm = int(f*60)
     26    ss = (f*60-mm)*60
     27   
     28    return sign*dd, mm, ss
    1429
    1530def redfearn(lat, lon):
     
    3247    zone_width = 6              #Degrees
    3348    false_easting = 500000
    34     false_northing = 10000000  #In the southern hemisphere (0 in the northern)
     49
     50    if lat < 0:
     51        false_northing = 10000000  #Southern hemisphere
     52    else:
     53        false_northing = 0         #Northern hemisphere)
    3554    longitude_of_central_meridian_zone1 = -177  #Needed???
    3655    longitude_of_central_meridian_zone0 = -183   
     
    116135    #Northing
    117136    term1 = nu*sinphi*cosphi*omega2/2 
    118     term2 = nu*sinphi*cosphi3*omega4/24*(4*psi2+psi-t2)
    119     term3 = nu*sinphi*cosphi5*omega6/720*\
     137    term2 = nu*sinphi*cosphi3*(4*psi2+psi-t2)*omega4/24
     138    term3 = nu*sinphi*cosphi5*\
    120139            (8*psi4*(11-24*t2)-28*psi3*(1-6*t2)+\
    121              psi2*(1-32*t2)-psi*2*t2+t4-t2)
    122     term4 = nu*sinphi*cosphi7*omega8/40320*(1385-3111*t2+543*t4-t6)
    123     sum = m + term1 + term2 + term3 + term4
    124     northing = false_northing + K0*sum
     140             psi2*(1-32*t2)-psi*2*t2+t4-t2)*omega6/720
     141    term4 = nu*sinphi*cosphi7*(1385-3111*t2+543*t4-t6)*omega8/40320
     142    northing = false_northing + K0*(m + term1 + term2 + term3 + term4)
    125143
    126     print northing, zone
    127 
    128     import sys; sys.exit()
     144    #Easting
     145    term1 = nu*omega*cosphi
     146    term2 = nu*cosphi3*(psi-t2)*omega3/6
     147    term3 = nu*cosphi5*(4*psi3*(1-6*t2)+psi2*(1+8*t2)-2*psi*t2+t4)*omega5/120
     148    term4 = nu*cosphi7*(61-479*t2+179*t4-t6)*omega7/5040
     149    sum = term1 + term2 + term3 + term4
     150    easting = false_easting + K0*sum
    129151   
    130152    return zone, easting, northing
  • inundation/ga/storm_surge/pyvolution/coordinate_transforms/test_redfearn.py

    r865 r868  
    1 
    2 
    3 
    4 #Latitude:  -37 57 03.7203
    5 #Longitude: 144 25 29.5244
    6 #Zone:   55   
    7 #Easting:  273741.297  Northing: 5796489.777
    8 #Latitude:   -37  57 ' 3.72030 ''  Longitude: 144  25 ' 29.52440 ''
    9 #Grid Convergence:  -1  35 ' 3.65 ''  Point Scale: 1.00023056
    10 
    111
    122from redfearn import *
    133from Numeric import allclose
     4
     5#http://www.cellspark.com/UTM.html
     6#http://www.ga.gov.au/nmd/geodesy/datums/redfearn_geo_to_grid.jsp
     7
    148
    159#TEST 1
     
    2317#Grid Convergence:  1  47 ' 19.36 ''  Point Scale: 1.00042107
    2418
    25 lat = degminsecs2decimal_degrees(-37,39,10.15610)
    26 lon = degminsecs2decimal_degrees(143,55,35.38390)
     19lat = degminsec2decimal_degrees(-37,39,10.15610)
     20lon = degminsec2decimal_degrees(143,55,35.38390)
     21assert allclose(lat, -37.65282114)
     22assert allclose(lon, 143.9264955)
     23
     24dd,mm,ss = decimal_degrees2degminsec(-37.65282114)
     25assert dd==-37
     26assert mm==39
     27assert allclose(ss, 10.15610)
     28
     29dd,mm,ss = decimal_degrees2degminsec(143.9264955)
     30assert dd==143
     31assert mm==55
     32assert allclose(ss, 35.38390)
     33
     34#print dd,mm,ss
     35
     36zone, easting, northing = redfearn(lat,lon)
     37
     38assert zone == 54
     39assert allclose(easting, 758173.797)
     40assert allclose(northing, 5828674.340)
    2741
    2842
    29 assert allclose(lat, -37.65282114)
    3043
     44#TEST 2
     45
     46#Latitude:  -37 57 03.7203
     47#Longitude: 144 25 29.5244
     48#Zone:   55   
     49#Easting:  273741.297  Northing: 5796489.777
     50#Latitude:   -37  57 ' 3.72030 ''  Longitude: 144  25 ' 29.52440 ''
     51#Grid Convergence:  -1  35 ' 3.65 ''  Point Scale: 1.00023056
     52
     53lat = degminsec2decimal_degrees(-37,57,03.7203)
     54lon = degminsec2decimal_degrees(144,25,29.5244)
     55print lat, lon
     56
     57zone, easting, northing = redfearn(lat,lon)
     58
     59assert zone == 55
     60assert allclose(easting, 273741.297)
     61assert allclose(northing, 5796489.777)
     62
     63
     64
     65#Test 3
     66lat = degminsec2decimal_degrees(-60,0,0)
     67lon = degminsec2decimal_degrees(130,0,0)
     68
     69zone, easting, northing = redfearn(lat,lon)
     70#print zone, easting, northing
     71
     72assert zone == 52
     73assert allclose(easting, 555776.267)
     74assert allclose(northing, 3348167.264)
     75
     76
     77#Test 4 (Kobenhavn)
     78lat = 55.70248
     79dd,mm,ss = decimal_degrees2degminsec(lat)
     80print dd, mm, ss
     81
     82lon = 12.58364
     83dd,mm,ss = decimal_degrees2degminsec(lon)
     84print dd, mm, ss
    3185
    3286zone, easting, northing = redfearn(lat,lon)
    3387print zone, easting, northing
    3488
    35 assert zone == 54
    36 assert easting == 758173.797
    37 assert northing == 5828674.340
     89assert zone == 33
     90assert allclose(easting, 348157.631)
     91#assert allclose(northing, 16175612.993) #With false_norting 10000000
     92assert allclose(northing, 6175612.993)
     93
     94
Note: See TracChangeset for help on using the changeset viewer.