座標轉換

本帖最後由 ghostkcleung 於 2023-3-21 11:05 編輯

平時我地用 Google Map 嘅座標叫做 WGS84,
我想將呢款坐標轉成 HK1980 grid system,
政府網站都有提供呢個 Tool,
但係我想 Offline 計,但係自己唔識測量,
啲數學符號我見都未見過,
請問有無師兄可以教吓我點計 ?

例如

22.291931, 114.162219
要轉成 817002.297, 834757.773

Thanks

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

python code
  1. from pyproj import Transformer
  2. Transformer.from_crs("EPSG:4326", "EPSG:2326").transform(22.291931,114.162219)
  3. Transformer.from_crs("EPSG:2326","EPSG:4326").transform(817002.297, 834757.773)
複製代碼

TOP

自己用 C 寫 native code 難唔難?

python code
chleung82 發表於 2023-3-21 13:47

TOP

本帖最後由 fred2088 於 2023-3-21 10:40 編輯

回復 3 #ghostkcleung

Try GPT

via HKEPC Reader for Android

As an AI language model, I cannot write a program in any specific programming language. However, I can provide the general steps that can be used to convert WGS84 coordinates to HK1980 grid system:

1. Obtain the WGS84 coordinates of the location you want to convert.
2. Convert the WGS84 coordinates to Hong Kong 1980 (HK1980) using the Helmert transformation parameters.
3. Apply the scale factor to the converted coordinates.
4. Convert the coordinates to the Hong Kong Grid System by applying the projection formula.

Here is a sample code in Python that can be used to perform the conversion:

```
# Import necessary libraries
import math

# Define constants
a = 6378137.0
f = 1/298.257223563
e2 = 2*f - f**2
k0 = 0.9996
dx = -162.0
dy = -39.0
dz = 178.0
rx = -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

TOP

真係,我用 ChatGPT 叫佢用 C 寫個 function 出嚟,
佢真係出到,依家試。

TOP

整體上係可行,但係有啲位以人嘅角度嚟講係寫得蠢咗啲,
例如佢 define 好多 constant ,其實可以 include ,
之類…不過已經好勁。

TOP

唔知你對座標有幾多認識,不過要用嚟個function,應該都識唔少
Wgs 84 要轉 hk1980 其實係個兩part 嘅過程
第一part 係將wgs84 轉hk80 datum
第二part 係將hk80 datum 轉 hk80 grid
地政處有份嘢叫 explanatory notes on geodetic datums in hong kong, 入面有數有formula做以上個兩part. 睇下幫唔幫到你

TOP

師兄唔好咁講,睇咗份嘢,
我就係正正見到啲數學符號已經 R 晒頭,
問咗 ChatGPT,好似有啲概念,
應該係將啲嘢代返入去咁上下,
小弟未接觸過微積分。

我想整一件玩具,一個 GPS Module ,
一塊 Arduino ( 可以係 Uno, mega, esp... )
一個顯示 ( 可以係 LCD TFT, 可以係 1602 ... )

GPS 直接透過 NMEA 讀取座標無難道,
將座標 print 出 display 亦無難度,
依家就係爭呢一步轉換。

唔知你對座標有幾多認識,不過要用嚟個function,應該都識唔少
Wgs 84 要轉 hk1980 其實係個兩part 嘅過程
...
hdyebx 發表於 2023-3-24 17:40

TOP

本帖最後由 hdyebx 於 2023-3-24 18:17 編輯

唔使微積分,應該都係代數同trig,等我研究下先。
ching 想整舊咁嘅嘢有咩用途?

TOP

無乜用途架其實,
成世人諗咗好多嘢,
攞一件係真正有用嘅都攞唔出,哈哈。

唔使微積分,應該都係代數同trig,等我研究下先。
ching 想整舊咁嘅嘢有咩用途? ...
hdyebx 發表於 2023-3-24 18:15

TOP