{"_id":"japan-choropleth","name":"japan-choropleth","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"japan-choropleth","version":"0.1.0","description":"Japanese polygon datasets with optional Leaflet choropleth helpers.","keywords":["japan","geojson","topojson","choropleth","leaflet","gis","map"],"author":{"name":"Kyodo News"},"license":"CC-BY-4.0","homepage":"https://github.com/kyodo-official/japan-choropleth#readme","repository":{"type":"git","url":"git+https://github.com/kyodo-official/japan-choropleth.git"},"bugs":{"url":"https://github.com/kyodo-official/japan-choropleth/issues"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","jsdelivr":"./dist/japan-choropleth.global.min.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./prefectures":{"types":"./dist/prefectures.d.ts","import":"./dist/prefectures.js"},"./municipalities":{"types":"./dist/municipalities.d.ts","import":"./dist/municipalities.js"},"./electoral-districts":{"types":"./dist/electoral-districts.d.ts","import":"./dist/electoral-districts.js"},"./municipality-district-intersections":{"types":"./dist/municipality-district-intersections.d.ts","import":"./dist/municipality-district-intersections.js"}},"scripts":{"build":"npm run build:types && npm run build:cdn","build:types":"tsc","build:cdn":"node scripts/build-cdn.mjs","typecheck":"tsc --noEmit","dev":"vite --host 0.0.0.0"},"dependencies":{"topojson-client":"^3.1.0"},"peerDependencies":{"leaflet":"^1.9.4"},"devDependencies":{"@types/geojson":"^7946.0.16","@types/leaflet":"^1.9.21","@types/topojson-client":"^3.1.5","typescript":"^5.9.3","vite":"^7.1.12"},"gitHead":"78f20994bcdd7afbbbf8bf0b8aeb88b9e314a713","_id":"japan-choropleth@0.1.0","_nodeVersion":"24.13.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-vl9JpTcK2ylqPbXZ2ZvzabB5VaHA5jPY5QucSNgiYjtMwCumdGKJBHGBMgtP903czj51Jm4gnr60TJWTmnjdZA==","shasum":"44054e83d39ab9ce310069d14eb3928d2c5c1b30","tarball":"https://registry.npmjs.org/japan-choropleth/-/japan-choropleth-0.1.0.tgz","fileCount":321,"unpackedSize":153546246,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD6YO1B629mlfokkqvLJcicyHzjmNTyGeJWmaflW5uuJwIhALBXbrhCCJ68RCPNwPIAqmkLtYP9ty4A1WI3ccrTc462"}]},"_npmUser":{"name":"kyodo","email":"data.investigative@gmail.com"},"directories":{},"maintainers":[{"name":"kyodo","email":"data.investigative@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/japan-choropleth_0.1.0_1778431562328_0.9574550701718585"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-10T16:46:02.327Z","0.1.0":"2026-05-10T16:46:03.259Z","modified":"2026-05-10T16:46:03.844Z"},"maintainers":[{"name":"kyodo","email":"data.investigative@gmail.com"}],"description":"Japanese polygon datasets with optional Leaflet choropleth helpers.","homepage":"https://github.com/kyodo-official/japan-choropleth#readme","keywords":["japan","geojson","topojson","choropleth","leaflet","gis","map"],"repository":{"type":"git","url":"git+https://github.com/kyodo-official/japan-choropleth.git"},"author":{"name":"Kyodo News"},"bugs":{"url":"https://github.com/kyodo-official/japan-choropleth/issues"},"license":"CC-BY-4.0","readme":"# japan-choropleth\n\n日本の行政区域・衆議院小選挙区のポリゴンデータと、コロプレス(塗り分け)地図を作成するための JavaScript パッケージです。JavaScriptの動作には[Leaflet](https://github.com/leaflet/Leaflet)が必要です。\n\nポリゴンデータだけを使うことも、付属の JavaScript でWeb向けのコロプレス地図を作成することもできます。`data/` には TopoJSON と GeoJSON のポリゴンデータ、`dist/` にはWeb用のJavaScriptを収録しています。\n\n![japan-choropleth の表示例](./example.png)\n\n## インストール\n\n```bash\nnpm install japan-choropleth leaflet\n```\n\nポリゴンデータのみ使用する場合や、JavaScriptをCDNから利用する場合はインストール不要です。(後述)\n\n## ポリゴンデータ\n\nポリゴンデータは `data/` 以下にあります。Web 配信には TopoJSON、GIS ツールやデータ加工には GeoJSON が向いています。\n\n| データ | 件数 | 全国版 | 都道府県別 |\n| --- | ---: | --- | --- |\n| 行政区域境界（都道府県） | 47 | あり | なし |\n| 行政区域境界（市区町村） | 1,905 | あり | あり |\n| 衆院小選挙区境界 | 289 | あり | あり |\n| 行政区域境界×小選挙区境界 | 1,927 | あり | あり |\n\n行政区域境界×小選挙区境界データを使うと、大規模市や特別区など、複数の小選挙区に分割された行政区域も小選挙区単位で塗り分けできます。(上記画像)\n\n全国版のファイルは次の通りです。\n\n```text\ndata/topojson/prefectures.topojson\ndata/topojson/municipalities.topojson\ndata/topojson/electoral-districts.topojson\ndata/topojson/municipality-district-intersections.topojson\n\ndata/geojson/prefectures.geojson\ndata/geojson/municipalities.geojson\ndata/geojson/electoral-districts.geojson\ndata/geojson/municipality-district-intersections.geojson\n```\n\n都道府県別ファイルは、都道府県コード2桁のディレクトリにあります。\n\n```text\ndata/topojson/by-prefecture/13/municipalities.topojson\ndata/topojson/by-prefecture/13/electoral-districts.topojson\ndata/topojson/by-prefecture/13/municipality-district-intersections.topojson\n\ndata/geojson/by-prefecture/13/municipalities.geojson\ndata/geojson/by-prefecture/13/electoral-districts.geojson\ndata/geojson/by-prefecture/13/municipality-district-intersections.geojson\n```\n\n### Flourish で使う\n\nFlourish でポリゴンデータを使用するには、`data/geojson/` 以下のファイルをアップロードしてください。\n\n1. Flourish で `Projection map (Blank)` を選びます。\n2. `Region geometry` タブに GeoJSON ファイルをアップロードします。\n3. `Data` タブで GeoJSON の geometry 列を指定します。\n4. `Geo region key` に、値データと結合するためのキー列を指定します。\n5. 値データ側にも同じキー列を用意します。\n\n[詳細はこちら(Flourish)](https://helpcenter.flourish.studio/hc/en-us/articles/8827954135951-How-to-add-your-own-map-regions)\n\n全国版の市区町村、小選挙区、市区町村×小選挙区はファイルサイズが大きいため、Flourish では都道府県別ファイルの利用を推奨します。キー列には、ポリゴンデータの `id` と同じ値を使います。\n\n## ID と属性\n\n| データ | `id` の例 | 内容 |\n| --- | --- | --- |\n| 都道府県 | `13` | 都道府県コード2桁 |\n| 市区町村 | `13102` | 市区町村コード5桁 |\n| 小選挙区 | `1302` | 小選挙区コード4桁 |\n| 市区町村×小選挙区 | `131021302` | 市区町村コード5桁 + 小選挙区コード4桁 |\n\n主な属性は次の通りです。\n\n| データ | 主な属性 |\n| --- | --- |\n| 都道府県 | `name` |\n| 市区町村 | `prefecture`, `subPrefecture`, `county`, `municipality`, `ward`, `displayName` |\n| 小選挙区 | `prefectureCode`, `districtNumber`, `name` |\n| 市区町村×小選挙区 | `municipalityCode`, `municipalityName`, `districtCode`, `districtName` |\n\n市区町村×小選挙区は、自治体と小選挙区の重なりを1 featureにしたものです。分区がある自治体では、同じ市区町村コードに複数の小選挙区コードが対応します。\n\nTopoJSON の object 名は次の通りです。\n\n| ファイル | object 名 |\n| --- | --- |\n| `prefectures.topojson` | `prefectures` |\n| `municipalities.topojson` | `municipalities` |\n| `electoral-districts.topojson` | `electoralDistricts` |\n| `municipality-district-intersections.topojson` | `municipalityDistrictIntersections` |\n\n## JavaScript でコロプレス地図を作成する\n\n付属の JavaScript をLeafletと同時に用いることで、Web向けのコロプレス地図を作成できます。\n\n### CDN で使う\n\n都道府県別の値を塗り分ける例です。\n\n```html\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.css\" />\n<div id=\"map\" style=\"height: 480px\"></div>\n\n<script src=\"https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/japan-choropleth@0.1.0/dist/prefectures.global.min.js\"></script>\n<script type=\"module\">\n  const map = L.map(\"map\", { center: [36.2, 138.25], zoom: 5 });\n\n  await JapanChoroplethPrefectures.createPrefectureChoropleth(\n    map,\n    [\n      { code: \"01\", value: 58.2 },\n      { code: \"13\", value: 55.7 }\n    ],\n    {\n      legend: {\n        title: \"投票率\",\n        unit: \"%\",\n        digits: 1\n      }\n    }\n  );\n</script>\n```\n\nJavaScriptのインポート時に必要な地図だけを指定することで、データ転送量を節約できます。\n\n| データ | CDN bundle | グローバル名 | メソッド名 |\n| --- | --- | --- | --- |\n| 都道府県 | `dist/prefectures.global.min.js` | `JapanChoroplethPrefectures` | `createPrefectureChoropleth` |\n| 市区町村 | `dist/municipalities.global.min.js` | `JapanChoroplethMunicipalities` | `createMunicipalityChoropleth` |\n| 小選挙区 | `dist/electoral-districts.global.min.js` | `JapanChoroplethElectoralDistricts` | `createElectoralDistrictChoropleth` |\n| 市区町村×小選挙区 | `dist/municipality-district-intersections.global.min.js` | `JapanChoroplethMunicipalityDistrictIntersections` | `createMunicipalityDistrictChoropleth` |\n\n### 入力データ\n\n入力データは `{code: string, value: number}` の配列です。\n\n```ts\n[\n  { code: \"13101\", value: 61.2 },\n  { code: \"13102\", value: 58.4 }\n]\n```\n\n`code` は地図の種類ごとに異なります。\n\n| 地図 | `code` の例 | 内容 |\n| --- | --- | --- |\n| 都道府県 | `13` | 2桁の都道府県コード |\n| 市区町村 | `13102` | 5桁の市区町村コード |\n| 小選挙区 | `1302` | 4桁の小選挙区コード |\n| 市区町村×小選挙区 | `131021302` | 市区町村コード5桁 + 小選挙区コード4桁 |\n\n### npm で使う\n\nnpm から利用する場合は、必要な地図だけを subpath import できます。TypeScriptにも対応しています。\n\n```bash\nnpm install japan-choropleth leaflet\n```\n\n```ts\nimport { createPrefectureChoropleth } from \"japan-choropleth/prefectures\";\nimport { createMunicipalityChoropleth } from \"japan-choropleth/municipalities\";\nimport { createElectoralDistrictChoropleth } from \"japan-choropleth/electoral-districts\";\nimport { createMunicipalityDistrictChoropleth } from \"japan-choropleth/municipality-district-intersections\";\n```\n\n市区町村別の値を塗り分ける例です。\n\nTopoJSON は、Web から読める場所に置いたうえで `topoJsonBaseUrl` にそのURLを指定します。以下の例では、同梱の `data/topojson/` を公開ディレクトリの `/topojson/` に置いています。\n\n```ts\nimport \"leaflet/dist/leaflet.css\";\nimport * as L from \"leaflet\";\nimport { createMunicipalityChoropleth } from \"japan-choropleth/municipalities\";\n\nconst map = L.map(\"map\").setView([36.2, 138.25], 5);\n\nawait createMunicipalityChoropleth(\n  map,\n  [\n    { code: \"13101\", value: 61.2 },\n    { code: \"13102\", value: 58.4 }\n  ],\n  {\n    min: 0,\n    max: 100,\n    topoJsonBaseUrl: \"/topojson/\"\n  }\n);\n```\n\n## 表示オプション\n\n既定の色は `0` が白、`100` が `rgb(151,0,5)` です。値がないポリゴンは塗りつぶしません。\n\n| オプション | 内容 |\n| --- | --- |\n| `min`, `max` | 色を割り当てる値域 |\n| `startColor`, `endColor` | グラデーションの両端の色 |\n| `legend` | 凡例のタイトル、単位、小数点以下の桁数など |\n| `prefCode` | 都道府県別 TopoJSON を読む場合の都道府県コード |\n| `topoJsonBaseUrl` | TopoJSON を置いたベースURL |\n| `topoJsonUrl` | 読み込む TopoJSON を直接指定 |\n| `tileLayer` | 背景地図のタイル設定。`false` で追加しません |\n| `popup` | 吹き出しの内容。`false` で表示しません |\n\n```ts\n{\n  min: 40,\n  max: 80,\n  legend: {\n    title: \"投票率\",\n    unit: \"%\",\n    digits: 1\n  }\n}\n```\n\n## サンプル\n\n共同通信集計の、第51回(2026年)衆院選の投票率を使った HTML サンプル兼テンプレートを `examples/` 以下に配置しています。\n\n```text\nexamples/prefectures.html\nexamples/municipalities.html\nexamples/electoral-districts.html\nexamples/municipality-district-intersections.html\n```\n\n\n## ライセンス\n\nCopyright (c) 2026 一般社団法人共同通信社\n\nJavaScript、TypeScript、ビルドスクリプト、サンプルコードなどのコード部分は MIT ライセンスで提供します。**`data/` 以下のポリゴンデータには MIT ライセンスを適用しません。出典元の利用条件に従ってください。**\n\n## 地図出典\n\njapan-choropleth の地図・ポリゴンデータは、以下を加工して作成しました。\n\n### 行政区域\n国土交通省 国土数値情報「[行政区域データ 2025年版](https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-2025.html)」([CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/))を加工。**二次利用にあたっては、原著者のクレジット表示などが必要です。**\n\n### 小選挙区\n地域・交通データ研究所(西澤明代表)「[衆議院議員選挙・小選挙区の統計データ及び地図データ](https://gtfs-gis.jp/senkyoku/)」(パブリックドメイン)を加工。\n\n### 背景地図(JavaScriptのみ)\n国土地理院「[地理院タイル](https://maps.gsi.go.jp/development/siyou.html)」を標準で使用します。背景地図を別のタイルに差し替える場合は、提供元の利用条件に従ってください。\n","readmeFilename":"README.md","_rev":"1-c6424c28efa979da3dac65b389e9867d"}