Last active
June 6, 2023 12:31
-
-
Save kawanet/96b7ba1e61caac7b6022f34866fdfb91 to your computer and use it in GitHub Desktop.
jp-neighboring-pref - 隣接都道府県の一覧をCSVで取り出す(MITライセンス) https://qiita.com/kawanet/items/f753df6249c14ef67a04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
01 | 北海道 | / | / | |
---|---|---|---|---|
02 | 青森県 | /03/05/ | /岩手県/秋田県/ | |
03 | 岩手県 | /02/04/05/ | /青森県/宮城県/秋田県/ | |
04 | 宮城県 | /03/05/06/07/ | /岩手県/秋田県/山形県/福島県/ | |
05 | 秋田県 | /02/03/04/06/ | /青森県/岩手県/宮城県/山形県/ | |
06 | 山形県 | /04/05/07/15/ | /宮城県/秋田県/福島県/新潟県/ | |
07 | 福島県 | /04/06/08/09/10/15/ | /宮城県/山形県/茨城県/栃木県/群馬県/新潟県/ | |
08 | 茨城県 | /07/09/11/12/ | /福島県/栃木県/埼玉県/千葉県/ | |
09 | 栃木県 | /07/08/10/11/ | /福島県/茨城県/群馬県/埼玉県/ | |
10 | 群馬県 | /07/09/11/15/20/ | /福島県/栃木県/埼玉県/新潟県/長野県/ | |
11 | 埼玉県 | /08/09/10/12/13/19/20/ | /茨城県/栃木県/群馬県/千葉県/東京都/山梨県/長野県/ | |
12 | 千葉県 | /08/11/13/ | /茨城県/埼玉県/東京都/ | |
13 | 東京都 | /11/12/14/19/ | /埼玉県/千葉県/神奈川県/山梨県/ | |
14 | 神奈川県 | /13/19/22/ | /東京都/山梨県/静岡県/ | |
15 | 新潟県 | /06/07/10/16/20/ | /山形県/福島県/群馬県/富山県/長野県/ | |
16 | 富山県 | /15/17/20/21/ | /新潟県/石川県/長野県/岐阜県/ | |
17 | 石川県 | /16/18/21/ | /富山県/福井県/岐阜県/ | |
18 | 福井県 | /17/21/25/26/ | /石川県/岐阜県/滋賀県/京都府/ | |
19 | 山梨県 | /11/13/14/20/22/ | /埼玉県/東京都/神奈川県/長野県/静岡県/ | |
20 | 長野県 | /10/11/15/16/19/21/22/23/ | /群馬県/埼玉県/新潟県/富山県/山梨県/岐阜県/静岡県/愛知県/ | |
21 | 岐阜県 | /16/17/18/20/23/24/25/ | /富山県/石川県/福井県/長野県/愛知県/三重県/滋賀県/ | |
22 | 静岡県 | /14/19/20/23/ | /神奈川県/山梨県/長野県/愛知県/ | |
23 | 愛知県 | /20/21/22/24/ | /長野県/岐阜県/静岡県/三重県/ | |
24 | 三重県 | /21/23/25/26/29/30/ | /岐阜県/愛知県/滋賀県/京都府/奈良県/和歌山県/ | |
25 | 滋賀県 | /18/21/24/26/ | /福井県/岐阜県/三重県/京都府/ | |
26 | 京都府 | /18/24/25/27/28/29/ | /福井県/三重県/滋賀県/大阪府/兵庫県/奈良県/ | |
27 | 大阪府 | /26/28/29/30/ | /京都府/兵庫県/奈良県/和歌山県/ | |
28 | 兵庫県 | /26/27/31/33/36/ | /京都府/大阪府/鳥取県/岡山県/徳島県/ | |
29 | 奈良県 | /24/26/27/30/ | /三重県/京都府/大阪府/和歌山県/ | |
30 | 和歌山県 | /24/27/29/ | /三重県/大阪府/奈良県/ | |
31 | 鳥取県 | /28/32/33/34/ | /兵庫県/島根県/岡山県/広島県/ | |
32 | 島根県 | /31/34/35/ | /鳥取県/広島県/山口県/ | |
33 | 岡山県 | /28/31/34/37/ | /兵庫県/鳥取県/広島県/香川県/ | |
34 | 広島県 | /31/32/33/35/38/ | /鳥取県/島根県/岡山県/山口県/愛媛県/ | |
35 | 山口県 | /32/34/40/ | /島根県/広島県/福岡県/ | |
36 | 徳島県 | /28/37/38/39/ | /兵庫県/香川県/愛媛県/高知県/ | |
37 | 香川県 | /33/36/38/ | /岡山県/徳島県/愛媛県/ | |
38 | 愛媛県 | /34/36/37/39/ | /広島県/徳島県/香川県/高知県/ | |
39 | 高知県 | /36/38/ | /徳島県/愛媛県/ | |
40 | 福岡県 | /35/41/43/44/ | /山口県/佐賀県/熊本県/大分県/ | |
41 | 佐賀県 | /40/42/ | /福岡県/長崎県/ | |
42 | 長崎県 | /41/ | /佐賀県/ | |
43 | 熊本県 | /40/44/45/46/ | /福岡県/大分県/宮崎県/鹿児島県/ | |
44 | 大分県 | /40/43/45/ | /福岡県/熊本県/宮崎県/ | |
45 | 宮崎県 | /43/44/46/ | /熊本県/大分県/鹿児島県/ | |
46 | 鹿児島県 | /43/45/ | /熊本県/宮崎県/ | |
47 | 沖縄県 | / | / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const {City} = require("jp-city-lookup"); | |
const {Pref} = require("jp-pref-lookup"); | |
for (let pref = 1; pref <= 47; pref++) { | |
const prefName = Pref.name(pref); | |
const prefCode = Pref.code(prefName); | |
const cities = City.lookup({pref}); | |
const neMap = {}; | |
for (const city of cities) { | |
const neighboring = City.lookup({neighboring: city}); | |
for (const neCity of neighboring) { | |
const nePref = neCity.substring(0, 2); | |
if (+pref !== +nePref) neMap[nePref] = 1; | |
} | |
} | |
const neList = Object.keys(neMap).sort(); | |
neList.unshift(""); | |
neList.push(""); | |
const nePref = neList.join("/"); | |
const neName = neList.map(p => Pref.name(p)).join("/"); | |
console.log([prefCode, prefName, nePref, neName].join(",")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment