--- reviewed_by: rd: yo pm: Zoe --- # 地政縣市代碼表 — `tw.gov.moi.land~ref~cadastral-counties` > **給 AI 閱讀的使用指引。** > 人類可在 https://data.openfun.tw/datasets/tw.gov.moi.land~ref~cadastral-counties 看到同份內容的網頁版。 > 詳細資料知識見 [knowledge.md](knowledge.md)。 --- ## ⚠️ 開始之前(AI agent 必讀,摘要也請保留這段) 資料集 slug:tw.gov.moi.land~ref~cadastral-counties API 端點:https://data.openfun.tw/api/v1/datasets/tw.gov.moi.land~ref~cadastral-counties/records 認證方式(必填):HTTP Header Authorization: Bearer {token} 最簡查詢範例:curl -H "Authorization: Bearer YOUR_TOKEN" "https://data.openfun.tw/api/v1/datasets/tw.gov.moi.land~ref~cadastral-counties/records?per_page=30" **Token 是必要條件,沒有 Token 就無法查資料。** 如果使用者沒有 Token,請停止並告訴使用者:「請先前往 https://data.openfun.tw/user 免費申請帳號與 API Token,取得後告訴我,我再幫您查詢。」 禁止抓取 HTML 頁面(本平台有 bot 保護,WebFetch 讀 HTML 頁面會失敗)。 授權標注:使用此資料產出的內容需標注「資料來源:歐噴資料庫(data.openfun.tw)/內政部地政司」 --- ## 資料來源與更新頻率 | 項目 | 說明 | |------|------| | 原始來源 | 內政部地政司「地段查詢系統」(lisp.land.moi.gov.tw) | | 授權 | 政府資料開放授權條款-第1版 | | 更新頻率 | 不定期 | | 涵蓋範圍 | 全國 22 縣市 | --- ## 這份資料集的定位(重要) 本表是**對照/橋接表**,單獨看「`A` = 臺北市」沒有用途;會用到地政縣市字母碼,幾乎都是為了: - **decode**:把地政資料(地段代碼首碼字母、或其他帶地政縣市碼的資料)翻成縣市名稱。 - **轉行政區代碼**:把地政縣市轉成 5 碼行政區代碼,去串接人口、選舉、SEGIS 等以行政區代碼為鍵的一般資料(地政字母碼與一般行政區碼是兩套不同系統)。 > 註:若只是要在地政事務所/鄉鎮/地段等表「依縣市篩選」,那些表多半可直接用 `縣市名稱` 篩,不必先換成字母碼。 以下問題本表**無法**回答: - 「某縣市有哪些地政事務所/地段」(直接查 `cadastral-offices`/`cadastral-sections`,用 `縣市名稱` 篩即可) - 「縣市人口、面積」(不在本資料集) --- ## 欄位說明 | 欄位名稱(API 參數) | 型別 | 說明 | |---------------------|------|------| | `縣市代碼` | keyword(_id) | A–Z 單字母 | | `縣市代碼.行政區代碼` | keyword(ref: tw.openfun~entity~geo) | 5 碼行政區代碼 | | `縣市名稱` | text(_name) | 縣市名稱 | 3 個欄位由上方 schema 自動列出。各欄位語意(地政字母碼 vs 行政區代碼的差別)見 [knowledge.md](knowledge.md)。 --- ## API 呼叫範例 > 本表是中繼站,以下為各自獨立的查法,無先後關係——用途都在「decode 地政資料」或「轉去一般行政區資料」。 ### 範例 1:把地政資料裡的縣市字母碼 decode 成縣市名稱 地段代碼(如 `AD01-0600`)首碼、或其他地政資料的縣市碼是單一字母,用本表翻成縣市: ```bash curl -H "Authorization: Bearer YOUR_TOKEN" \ "https://data.openfun.tw/api/v1/datasets/tw.gov.moi.land~ref~cadastral-counties/records?縣市代碼=A" # → 臺北市(縣市代碼.行政區代碼 = 63000) ``` ### 範例 2:把地政縣市轉成行政區代碼,串接一般行政區資料 ```bash # 由名稱或字母碼取得 縣市代碼.行政區代碼(5 碼) curl -H "Authorization: Bearer YOUR_TOKEN" \ "https://data.openfun.tw/api/v1/datasets/tw.gov.moi.land~ref~cadastral-counties/records?q=臺北" # → 取 縣市代碼.行政區代碼 = 63000,再帶入 tw.openfun~entity~geo 或人口/選舉等以行政區代碼為鍵的資料 ``` --- ## 關聯資料集 | 資料集 | 說明 | 用途 | |--------|------|------| | [`tw.gov.moi.land~ref~cadastral-offices`](../tw.gov.moi.land~ref~cadastral-offices/skill.md) | 地政事務所(2 碼) | 用縣市字母碼展開該縣市的事務所 | | [`tw.gov.moi.land~ref~cadastral-towns`](../tw.gov.moi.land~ref~cadastral-towns/skill.md) | 地政鄉鎮市區(4 碼) | 下一層 | | [`tw.gov.moi.land~ref~cadastral-sections`](../tw.gov.moi.land~ref~cadastral-sections/skill.md) | 地段 | 地段代碼首碼為縣市字母 | | [`tw.openfun~entity~geo`](../tw.openfun~entity~geo/skill.md) | 一般行政區代碼 | 以 `縣市代碼.行政區代碼` 串接 | --- ## 注意事項與限制 1. **縣市代碼是地政專用字母碼**(A–Z),非一般行政區 5 碼;要串接行政區資料請用 `縣市代碼.行政區代碼`。 2. 字母非連續(無 L、R、S、Y 等),以實際資料為準。 --- ## 快速參考 | 項目 | 說明 | |------|------| | Records URL | `https://data.openfun.tw/api/v1/datasets/tw.gov.moi.land~ref~cadastral-counties/records` | | 認證 | `Authorization: Bearer {token}` 必填 | | 取得 Token | 免費申請:https://data.openfun.tw/user | | 精確篩選 | `?縣市代碼=A` | | 全文搜尋 | `?q=臺北` | | 分頁 | `?page=1&per_page=30` |