🗺️ 開源地圖資料集
台灣的形狀
SVG、GeoJSON、TopoJSON — 給開發者、設計師、研究者的完整開源地圖資料。
為什麼台灣的形狀重要
讓任何一款 AI 畫圖工具畫台灣,出來的幾乎都是一顆圓圓胖胖、介於橄欖和馬鈴薯之間的東西。台灣不是橄欖。它是一條 394 公里長的番薯,有一條縱貫南北的中央山脈,還有一百多座離島。
把形狀畫對,不只是設計細節,是身份問題。這個頁面收集我們在 taiwan.md 上使用的所有開源地圖素材,讓任何人都能在自己的專案裡精確地呈現台灣。
🤖 vs. 🇹🇼 — AI 每次都畫錯,真的
📐 SVG 輪廓 — 直接嵌入
四組精選 SVG 檔案,全部是 CC 授權或公有領域。可以直接丟進任何網頁、App 或設計稿。
使用方式
<!-- HTML -->
<img src="https://taiwan.md/assets/svg/taiwan-icon-wiki.svg" alt="Taiwan" width="200">
/* CSS */
background-image: url('https://taiwan.md/assets/svg/taiwan-icon-wiki.svg');
<!-- Markdown -->
 所有 SVG 皆為 Creative Commons 授權或公有領域。標註來源為佳但非必要。
🌐 TopoJSON — 縣市級互動地圖
如果你要做的是互動地圖——縮放、滑鼠懸停、用資料值填色——你需要的不是 SVG 路徑,而是真正的地理座標資料。我們打包了從 Waiting 的 taiwan-vue-components(MIT 授權,2018)萃取的 TopoJSON 檔案。
TopoJSON 是 GeoJSON 的壓縮版:相鄰縣市共用的邊界只儲存一次,檔案小 80%。用 topojson-client 可以即時轉回 GeoJSON。
TopoJSON vs GeoJSON — 該選哪一個
TopoJSON:檔案小、相鄰區域共用邊界、適合做網頁互動地圖。
GeoJSON:格式簡單、直接相容 Python geopandas、QGIS 和多數 GIS 工具。
全國輪廓(22 個縣市)
約 21 KB 的 TopoJSON 檔案,包含 22 個縣市與直轄市,每個都是獨立的 feature。做 choropleth 地圖的起點。
taiwan-country.topo.json六都鄉鎮級資料
我們打包了六都的鄉鎮級 TopoJSON 檔案。其他 16 個縣市的檔案請到原始 GitHub repo 下載。
taiwan-towns-63000.topo.json taiwan-towns-64000.topo.json taiwan-towns-65000.topo.json taiwan-towns-66000.topo.json taiwan-towns-67000.topo.json taiwan-towns-68000.topo.json 完整 22 縣市鄉鎮檔案請見 github.com/waiting7777/taiwan-vue-components.
🧭 行政區代碼對照表
台灣的行政區使用數字代碼編碼。以下是 22 個縣市級行政區的對照表(檔名規則:`towns-{code}.json`)。
| 代碼 | 行政區 | 類型 |
|---|---|---|
63000 | 臺北市 Taipei | 直轄市 |
64000 | 高雄市 Kaohsiung | 直轄市 |
65000 | 新北市 New Taipei | 直轄市 |
66000 | 臺中市 Taichung | 直轄市 |
67000 | 臺南市 Tainan | 直轄市 |
68000 | 桃園市 Taoyuan | 直轄市 |
10002 | 宜蘭縣 Yilan | 縣 |
10004 | 新竹縣 Hsinchu | 縣 |
10005 | 苗栗縣 Miaoli | 縣 |
10007 | 彰化縣 Changhua | 縣 |
10008 | 南投縣 Nantou | 縣 |
10009 | 雲林縣 Yunlin | 縣 |
10010 | 嘉義縣 Chiayi | 縣 |
10013 | 屏東縣 Pingtung | 縣 |
10014 | 臺東縣 Taitung | 縣 |
10015 | 花蓮縣 Hualien | 縣 |
10016 | 澎湖縣 Penghu | 縣 |
10017 | 基隆市 Keelung | 市 |
10018 | 新竹市 Hsinchu City | 市 |
10020 | 嘉義市 Chiayi City | 市 |
09007 | 連江縣 Lienchiang (Matsu) | 離島縣 |
09020 | 金門縣 Kinmen | 離島縣 |
💻 使用範例
D3.js — 互動 choropleth
// D3.js v7 + topojson-client
import * as d3 from 'd3';
import * as topojson from 'topojson-client';
const topo = await d3.json('https://taiwan.md/assets/geo/taiwan-country.topo.json');
const counties = topojson.feature(topo, topo.objects.map);
const projection = d3.geoMercator()
.center([121, 24])
.scale(8000)
.translate([400, 300]);
const path = d3.geoPath().projection(projection);
d3.select('svg')
.selectAll('path')
.data(counties.features)
.join('path')
.attr('d', path)
.attr('fill', d => colorScale(d.properties.value))
.attr('stroke', '#333'); Python — geopandas
# Python — convert TopoJSON to GeoDataFrame
import json, geopandas as gpd
from topojson import Topology
with open('taiwan-country.topo.json') as f:
topo = json.load(f)
# Convert to GeoJSON
topology = Topology(topo)
gdf = gpd.GeoDataFrame.from_features(
topology.to_geojson()['features']
)
gdf.plot(column='name', legend=True) Leaflet — 瓦片地圖疊圖
// Leaflet + topojson
import L from 'leaflet';
import * as topojson from 'topojson-client';
const map = L.map('map').setView([24, 121], 7);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
fetch('https://taiwan.md/assets/geo/taiwan-country.topo.json')
.then(r => r.json())
.then(topo => {
const geojson = topojson.feature(topo, topo.objects.map);
L.geoJSON(geojson, {
style: { color: '#4a90e2', weight: 1, fillOpacity: 0.3 }
}).addTo(map);
}); Vue — taiwan-vue-components
// Vue 2 — taiwan-vue-components (original source)
npm install taiwan-vue-components
// In your Vue component
import { Country, Taipei, Kaohsiung } from 'taiwan-vue-components';
<template>
<div>
<Country :width="400" :height="600" fill="#f0f0f0" stroke="#333" />
<Taipei :width="300" :height="300" />
</div>
</template> 📚 其他開源資料來源
如果你需要的比這裡打包的更多——更高解析度、不同投影、歷史行政區界——以下是我們推薦的來源:
- 政府資料開放平臺 (data.gov.tw) — 政府官方開放資料平台,包含內政部發布的行政區界 shapefile。
- Natural Earth — 公有領域全球地圖資料,1:10m / 1:50m / 1:110m 三種比例尺。適合做含台灣的世界地圖。
- OpenStreetMap (Taiwan relation) — OSM 社群編輯的台灣地圖,可透過 Overpass API 與 Geofabrik 下載 OSM XML 或 PBF。
- GADM — Taiwan — 全球行政區資料庫,台灣行政區界 0-3 級,提供 Shapefile / GeoPackage / KMZ / R 格式。
- g0v.tw — 台灣公民科技社群。許多 g0v 專案以開源形式發布整理過的地圖資料和視覺化。
⚖️ 授權與出處
這個頁面上的每個檔案都是開源的。以下是完整的來源與授權資訊:
- taiwan-icon-wiki.svg · taiwan-location-map.svg · taiwan-political-division.svg — Wikimedia Commons,Creative Commons 授權。
- taiwan-simplemaps.svg — SimpleMaps,標註來源後可免費商業使用。
- taiwan-country.topo.json · taiwan-towns-*.topo.json — 出自 waiting7777/taiwan-vue-components, MIT License © 2018 Waiting.