座标转换

本帖最后由 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