Geography 板


LINE

我自己照著 http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.htm 寫的公式寫了一個從lat/lon轉TWD97的python程式 from math import tan, sin, cos, radians class LatLonToTWD97(object): """This object provide method for converting lat/lon coordinate to TWD97 coordinate the formula reference to http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.htm (there is lots of typo) http://www.offshorediver.com/software/utm/Converting UTM to Latitude and Longitude.doc Parameters reference to http://rskl.geog.ntu.edu.tw/team/gis/doc/ArcGIS/WGS84%20and%20TM2.htm http://blog.minstrel.idv.tw/2004/06/taiwan-datum-parameter.html """ def __init__(self, ): # Equatorial radius self.a = 6378137.0 # Polar radius self.b = 6356752.314245 # central meridian of zone self.long0 = radians(121) # scale along long0 self.k0 = 0.9999 # eccentricity of the earth's elliptical cross-section self.e = (1-self.b**2/self.a**2)**0.5 # delta x in meter self.dx = 250000 def convert(self, lat, lon): """Convert lat lon to twd97 """ a = self.a b = self.b long0 = self.long0 k0 = self.k0 e = self.e dx = self.dx e2 = e**2/(1-e**2) n = (a-b)/(a+b) nu = a/(1-(e**2)*(sin(lat)**2))**0.5 p = lon-long0 A = a*(1 - n + (5/4.0)*(n**2 - n**3) + (81/64.0)*(n**4 - n**5)) B = (3*a*n/2.0)*(1 - n + (7/8.0)*(n**2 - n**3) + (55/64.0)*(n**4 - n**5)) C = (15*a*(n**2)/16.0)*(1 - n + (3/4.0)*(n**2 - n**3)) D = (35*a*(n**3)/48.0)*(1 - n + (11/16.0)*(n**2 - n**3)) E = (315*a*(n**4)/51.0)*(1 - n) S = A*lat - B*sin(2*lat) + C*sin(4*lat) - D*sin(6*lat) + E*sin(8*lat) K1 = S*k0 K2 = k0**nu*sin(2*lat)/4.0 K3 = (k0*nu*sin(lat)*(cos(lat)**3)/24.0) * \ (5 - tan(lat)**2 + 9*e2*(cos(lat)**2) + 4*(e2**2)*(cos(lat)**4)) y = K1 + K2*(p**2) + K3*(p**4) K4 = k0*nu*cos(lat) K5 = (k0*nu*(cos(lat)**3)/6.0) * \ (1 - tan(lat)**2 + e2*(cos(lat)**2)) x = K4*p + K5*(p**3) + self.dx return x, y 公式本身我檢查好幾次了,應該是沒有打錯了,包括網頁裡打錯的部份 像51被誤打成512,然後an被打成tan也都有修正 可是不知道為什麼,算出來的結果lat誤差都在公尺之內,而lon總是有幾十公尺的誤差 像是我用這裡面的三角點資料來做測試 http://wiki.osgeo.org/index.php?title=Taiwan_datums/Test_points&uselang=zh-tw 挑個七星山當輸入的話 25.17069939, 121.5534442 我的程式算出來的結果是 305787.782217, 2784684.75762 而裡面寫的資料是 305787.783, 2784799.355 可以發現lat幾乎都很精準 而lon卻差了-114.59738公尺 不只是那三角點的資料,我也有找其它轉換程式去算 結果也都是lat誤差在公尺以下,而long誤差在十幾公尺到上百公尺 請問我可能是哪裡弄錯了? 參數弄錯? 還是? 為什麼會有這long誤差這麼大的問題? 因為這要拿來當做導航用的,long誤差百公尺可以從路面跑進河裡或任何地方 囧 以上,謝謝 -- 哇咧咧 創意投票系統 http://walele.com 易記學 程式設計教學 http://ez2learn.com/ 易記學 程式設計討論區 http://forum.ez2learn.com VICTOR's 個人Blog http://blog.ez2learn.com/ 財報分析王 http://victorlin.serveftp.org/stock/ --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.165.225.76
1F:→ nehex:E = (315*a*(n**4)/512.0)*(1 - n) 08/13 18:05
2F:→ nehex: ^^^ 08/13 18:06
3F:→ nehex:另 geog.ntu 那個網頁也不建議使用 @@ 08/13 18:13
4F:→ nehex:噢噢 doc 的 反而又錯了 :P 08/13 18:17
5F:→ nehex:llh tm 互轉誤差是可以無視的... @@ 08/13 18:23
6F:→ nehex:= = 不管是 512 還是 51 都不影響 08/13 18:50







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Gossiping站內搜尋

TOP