香港地理編碼(HKGCode)將冗長的經緯度化為簡短代碼,讓位置分享如報車牌般簡單。其三層網格設計精細達5米範圍,完美解決精確定位的溝通痛點。立即探索編碼原理,並在 HK GeoTiles 地圖上親身體驗!
香港地政總署推出了一套專為本地設計的「香港地理編碼」(HKGCode)。這套系統以大家熟悉的香港1980方格網(HK80,EPSG:2326)為基礎,把全港劃分成不同大小的網格。每個網格都有專屬的簡短代碼,讓精確定位與位置分享變得像報車牌一樣簡單!
為什麼需要 HKGCode?
雖然大家常用的 WGS84 GPS 經緯度(例如 22.29365°N, 114.16955°E)非常準確,但那一長串數字實在太難記,在日常口頭或文字溝通中也容易出錯。
HKGCode 完美解決了這個痛點,用簡短、好讀的代碼代替冗長的座標。這套系統特別適合以下場景:
- 日常位置分享與溝通
- 地理數據採集與統計
- 物流與運輸派送
- 緊急救援行動
- 戶外設施與資產管理
- 發展中的低空經濟(如無人機配送)
HKGCode 三層網格 16x9

HKGCode 蚺蛇尖

三層格網結構
HKGCode 的設計就像俄羅斯套娃,採用「三層遞進」的網格設計。代碼越長,定位越精準!每一層都由兩個英數字元組成:
第一層:地區碼(Region)— 2 字元,2000 米 × 2000 米
系統首先將整個 HKGCode 覆蓋範圍(HK80 東距 800,000–864,000 米,北距 800,000–848,000 米)切分成 768 個大網格(32 × 24),每一格面積為 4 平方公里。
代碼使用了 32 進制字母表(Base32):0123456789ABCDEFGHJKMNPQRSTVWXYZ。為了避免視覺混淆,官方刻意剔除了 I、L、O、U 四個字母。每對字元分別代表網格在東向和北向的座標索引。
例子:WG 代表了覆蓋西貢的一個 2 公里 × 2 公里大範圍。
第二層:地點碼(Site)— 4 字元,100 米 × 100 米
在地區碼後面加上兩個字元,就能把原本 2 公里的大網格,進一步細分為 400 個 100 米 × 100 米的中型網格。
例子:WG73 代表西貢蚺蛇尖附近區內某個 100 米 × 100 米的具體地段。
第三層:標準碼(Standard)— 6 字元,5 米 × 5 米
這是最精確的一層!再加兩個字元,中型網格會再被切分成 400 個 5 米 × 5 米的小方格。
例子:WG73JD 代表了一個 5 米 × 5 米的精準位置,這個範圍已經足夠準確地標示出蚺蛇尖三角測量站。
蚺蛇尖三角測量站

編碼原理
對於喜歡探究技術細節的讀者,HKGCode 的運作原理其實非常直觀,主要分為三個步驟:
第一步:座標轉換
先將我們常用的 WGS84 經緯度,轉換成 HK80 方格網座標(東距 E、北距 N,單位為米)。地政總署提供了一組便捷的近似偏移量(緯度 +5.5″,經度 −8.8″)來進行轉換,日常使用的精度大約在 2 到 5 米之間。
第二步:計算格網索引
以 HKGCode 的西南角原點(HK80 E=800,000, N=800,000)作為基準,計算出目標位置的相對距離:
e = hkE - 800000
n = hkN - 800000
地區索引:rE = floor(e / 2000),rN = floor(n / 2000)
地點索引:sE = floor((e % 2000) / 100),sN = floor((n % 2000) / 100)
標準索引:tE = floor((e % 100) / 5),tN = floor((n % 100) / 5)
第三步:查表編碼
最後,把算出來的索引數字對應到 Base32 字母表,按順序拼起來,就得出最終的代碼了。
HKGCode 全境水彩 網格標示

覆蓋範圍與邊界
HKGCode 專為香港量身定制,其有效邊界範圍如下:
| 邊界 | HK80 東距 (m) | HK80 北距 (m) |
|---|---|---|
| 西南角(包含) | 800,000 | 800,000 |
| 東北角(不含) | 864,000 | 848,000 |
💡 小貼士:網格計算採用的是數學上的「半開區間」原則——即包含左下(西南)邊界,但不包含右上(東北)邊界。因此,全港最東北角的 5 米網格代碼是 ZQKKKK,而不是部分文件誤植的 ZZKKKK。
在 HK GeoTiles 地圖上使用
如果你想親身體驗,HK GeoTiles 的地圖介面已經完美整合了 HKGCode 的顯示功能。地圖會根據你的縮放比例,智能切換網格層級:
- 縮放層級 8–16:顯示 2 公里的地區格網
- 縮放層級 17–19:顯示 100 米的地點格網
- 縮放層級 20:顯示最精確的 5 米標準格網
此外,只要打開地圖的 GNSS(定位)面板,系統就會即時顯示你目前位置的 HKGCode,並支援一鍵複製或分享,非常方便!
互動示範工具
說了這麼多,不如親自試試看!我們準備了以下的互動工具,讓你輕鬆測試 HKGCode 的編碼與解碼功能:
- 座標轉代碼:輸入常見的經緯度,選擇想要的精細度,馬上獲得專屬代碼。
- 代碼轉座標:輸入任意 2、4 或 6 個字元的 HKGCode,就能反向找出該網格的中心座標。
- 地圖隨意探索:直接在地圖上移動滑鼠或點擊,即時查看該處的 HKGCode。
精度說明
在實際應用 HKGCode 時,有幾點技術細節需要特別留意:
參考資料
想深入了解更多技術細節?可以參考以下官方資源:
English Summary
The Hong Kong Lands Department has introduced the Hong Kong Geographic Code, commonly known as HKGCode, to streamline location sharing and spatial data management across the territory. While traditional global positioning systems rely on WGS84 latitude and longitude coordinates, these lengthy numerical strings are often prone to human error during verbal communication or manual data entry. To resolve this, HKGCode offers a highly localised, alphanumeric shorthand built specifically upon the foundational Hong Kong 1980 Grid system, technically designated as EPSG:2326. By translating complex geospatial coordinates into concise, easily readable codes, the system significantly improves operational efficiency for a wide array of practical applications. This streamlined approach to location identification is particularly beneficial for emergency rescue operations, logistics and transportation, outdoor asset management, and the rapidly developing low-altitude economy, such as drone-based delivery services. For geographic information system professionals and researchers, it provides a robust, standardised framework for efficient spatial data collection and statistical analysis within the region.
At its core, the HKGCode architecture employs a nested, three-tiered grid structure that progressively refines spatial accuracy as the code lengthens. The system covers a designated territorial bounding box—spanning from 800,000 to 864,000 metres in Easting and 800,000 to 848,000 metres in Northing—and calculates grid indices from a southwestern origin point. The encoding relies on a modified Base32 alphabet, deliberately excluding the letters I, L, O, and U to eliminate visual ambiguity. The first tier, known as the Region code, utilises just two characters to define a broad two-kilometre by two-kilometre area, dividing the territory into 768 macroscopic grids. By appending two additional characters, the system generates a four-character Site code that narrows the location down to a one-hundred-metre by one-hundred-metre square. The most precise tier, the Standard code, features six characters and pinpoints a highly specific five-metre by five-metre grid. For instance, while a two-character code might denote the general vicinity of the Sai Kung peninsula, its six-character counterpart can accurately isolate the exact placement of the Sharp Peak Trigonometrical Station. Furthermore, the mathematical model adheres to a semi-open interval logic, meaning each grid is inclusive of its southwestern boundaries but exclusive of its northeastern edges, ensuring mathematical consistency across the entire grid network.
To seamlessly bridge this official framework with practical mapping applications, the HK GeoTiles platform has deeply integrated the HKGCode system into its user interface, offering a highly dynamic experience for spatial exploration. As users interact with the historical and modern map layers, the platform intelligently renders the appropriate grid overlays based on the current zoom level. Broad regional grids are displayed at zoom levels eight through sixteen, intermediate site grids appear between levels seventeen and nineteen, and the highly precise standard grids are revealed at a maximum zoom level of twenty. This responsive visualisation allows users to intuitively grasp the spatial hierarchy of the encoding system. Additionally, HK GeoTiles features a dedicated global navigation satellite system panel that instantly calculates and displays the user's current HKGCode, facilitating effortless one-click copying and sharing. The platform also provides a suite of interactive demonstration tools, enabling bidirectional conversions between standard WGS84 coordinates and HKGCodes, thereby allowing researchers to smoothly translate historical georeferenced data into modern shorthand or reverse-engineer codes back into spatial polygons.
For geographic information system professionals, land surveyors, and history enthusiasts utilising HKGCode for precise mapping or archival georeferencing, several technical nuances must be carefully considered. Primarily, it is crucial to understand that an HKGCode fundamentally represents a spatial area—ranging from twenty-five square metres to four square kilometres—rather than a singular, dimensionless point. Consequently, when a code is algorithmically decoded back into conventional coordinates, the resulting output will invariably represent the geometric centroid of that specific grid, not the original pinpoint location. Furthermore, standard everyday conversions between WGS84 and the local HK80 datum rely on simplified offset approximations, which naturally introduce a marginal discrepancy of roughly two to five metres. In edge cases, this minor deviation can occasionally shift a coordinate situated exactly on a boundary line into an adjacent grid cell. Therefore, while the built-in conversion tools are perfectly adequate for general historical mapping, everyday logistics, and rapid location sharing, professionals engaging in rigorous land boundary surveying, legal documentation, or strict asset mapping are strongly advised to utilise the official Lands Department application programming interfaces, which execute precise geodetic transformations based on the stringent ITRF96 datum.
HK GeoTiles
HK GeoTiles 撰稿人
致力於整理及分享香港歷史地圖磚資源,讓公眾更容易取用珍貴的地理資訊。
相關文章
查看全部
教學1963年香港航拍:從一幅大圖到可以放大的地圖
將1963年香港航拍大圖轉為可隨意縮放的網頁地圖,仰賴精準的坐標轉換與圖磚技術。這打破了巨型檔案的讀取限制,讓網頁能按需流暢載入影像。圖磚並未改寫歷史細節,而是徹底革新我們探索舊日城市風貌的方式。
教學拖曳、縮放之間:從香港中環看懂地圖圖磚 Map Tiles
網頁地圖能流暢拖曳與縮放,全靠背後按需載入的「地圖圖磚」拼圖金字塔。透過香港中環真實案例,帶你拆解 XYZ 網格與圖磚技術的運作機制。掌握這套邏輯,你將明白為何無限放大地圖,並不等於擁有更精準的細節。
自然環境數碼地圖上的生態多樣性:香港圖磚帶你遊歷21種特色生境
跟著地圖仔與行山女走遍六大站,輕鬆解碼香港21種陸地生境!從山野植被到市區海岸,辨別生態不能單憑表面綠意或水流,更需細察植物比例與底層泥石。立即探索這份指南,發掘隱藏在我們腳下的多元棲息地。
