Skip to content

Instantly share code, notes, and snippets.

@ofutondaisuki
Last active November 12, 2015 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ofutondaisuki/991ecfc5fd49ad2cdd5f to your computer and use it in GitHub Desktop.
Save ofutondaisuki/991ecfc5fd49ad2cdd5f to your computer and use it in GitHub Desktop.
都道府県別人口

#都道府県別人口(1920〜2010年) 出典:統計局ホームページ 第六十四回日本統計年鑑 平成27年-第2章 人口・世帯 2 - 3 都道府県別人口

大正9年からのデータなので見ていて楽しいです。

※1945年沖縄県:データがないため1940年沖縄県のデータを引用。
※1950年沖縄県:奄美群島の人口を含む。
※1960年長野県:岐阜県との境界紛争地域の人口を含む。
※昭和20年以前は現在人口,25年以降は常住人口である。沖縄県は昭和25年以前が現在人口,30年以降が常住人口である。

Built with blockbuilder.org

ken 1920 1925 1930 1935 1940 1945 1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010
北海道 2359 2499 2812 3068 3273 3518 4296 4773 5039 5172 5184 5338 5576 5679 5644 5692 5683 5628 5506
青森県 756 813 880 967 1001 1083 1283 1383 1427 1417 1428 1469 1524 1524 1483 1482 1476 1437 1373
岩手県 846 901 976 1046 1096 1228 1347 1427 1449 1411 1371 1386 1422 1434 1417 1420 1416 1385 1330
宮城県 962 1044 1143 1235 1271 1462 1663 1727 1743 1753 1819 1955 2082 2176 2249 2329 2365 2360 2348
秋田県 899 936 988 1038 1052 1212 1309 1349 1336 1280 1241 1232 1257 1254 1227 1214 1189 1146 1086
山形県 969 1027 1080 1117 1119 1326 1357 1354 1321 1263 1226 1220 1252 1262 1258 1257 1244 1216 1169
福島県 1363 1438 1508 1582 1626 1957 2062 2095 2051 1984 1946 1971 2035 2080 2104 2134 2127 2091 2029
茨城県 1350 1409 1487 1549 1620 1944 2039 2064 2047 2056 2144 2342 2558 2725 2845 2956 2986 2975 2970
栃木県 1046 1090 1142 1195 1207 1546 1550 1548 1514 1522 1580 1698 1792 1866 1935 1984 2005 2017 2008
群馬県 1053 1119 1186 1242 1299 1546 1601 1614 1578 1606 1659 1756 1849 1921 1966 2004 2025 2024 2008
埼玉県 1320 1394 1459 1529 1608 2047 2146 2263 2431 3015 3866 4821 5420 5864 6405 6759 6938 7054 7195
千葉県 1336 1399 1470 1546 1588 1967 2139 2205 2306 2702 3367 4149 4735 5148 5555 5798 5926 6056 6216
東京都 3699 4485 5409 6370 7355 3488 6278 8037 9684 10869 11408 11674 11618 11829 11856 11774 12064 12577 13159
神奈川県 1323 1417 1620 1840 2189 1866 2488 2919 3443 4431 5472 6398 6924 7432 7980 8246 8490 8792 9048
新潟県 1776 1850 1933 1996 2064 2390 2461 2473 2442 2399 2361 2392 2451 2478 2475 2488 2476 2431 2374
富山県 724 749 779 799 823 954 1009 1021 1033 1025 1030 1071 1103 1118 1120 1123 1121 1112 1093
石川県 747 751 757 768 758 888 957 966 973 980 1002 1070 1119 1152 1165 1180 1181 1174 1170
福井県 599 598 618 647 644 725 752 754 753 751 744 774 794 818 824 827 829 822 806
山梨県 583 601 631 647 663 839 811 807 782 763 762 783 804 833 853 882 888 885 863
長野県 1563 1629 1717 1714 1711 2121 2061 2021 1982 1958 1957 2018 2084 2137 2157 2194 2215 2196 2152
岐阜県 1070 1133 1178 1226 1265 1519 1545 1584 1638 1700 1759 1868 1960 2029 2067 2100 2108 2107 2081
静岡県 1550 1671 1798 1940 2018 2220 2471 2650 2756 2913 3090 3309 3447 3575 3671 3738 3767 3792 3765
愛知県 2090 2319 2567 2863 3167 2858 3391 3769 4206 4799 5386 5924 6222 6455 6691 6868 7043 7255 7411
三重県 1069 1108 1157 1175 1199 1394 1461 1486 1485 1514 1543 1626 1687 1747 1793 1841 1857 1867 1855
滋賀県 651 662 692 711 704 861 861 854 843 853 890 986 1080 1156 1222 1287 1343 1380 1411
京都府 1287 1406 1553 1703 1730 1604 1833 1935 1993 2103 2250 2425 2527 2587 2602 2630 2644 2648 2636
大阪府 2588 3060 3540 4297 4793 2801 3857 4618 5505 6657 7620 8279 8473 8668 8735 8797 8805 8817 8865
兵庫県 2302 2455 2646 2923 3221 2822 3310 3621 3906 4310 4668 4992 5145 5278 5405 5402 5551 5591 5588
奈良県 565 584 596 620 621 780 764 777 781 826 930 1077 1209 1305 1375 1431 1443 1421 1401
和歌山県 750 788 831 864 865 936 982 1007 1002 1027 1043 1072 1087 1087 1074 1080 1070 1036 1002
鳥取県 455 472 489 490 484 563 600 614 599 580 569 581 604 616 616 615 613 607 589
島根県 715 722 740 747 741 860 913 929 889 822 774 769 785 795 781 771 762 742 717
岡山県 1218 1238 1284 1333 1329 1565 1661 1690 1670 1645 1707 1814 1871 1917 1926 1951 1951 1957 1945
広島県 1542 1618 1692 1805 1870 1885 2082 2149 2184 2281 2436 2646 2739 2819 2850 2882 2879 2877 2861
山口県 1041 1095 1136 1191 1294 1356 1541 1610 1602 1544 1511 1555 1587 1602 1573 1556 1528 1493 1451
徳島県 670 690 717 729 719 836 879 878 847 815 791 805 825 835 832 832 824 810 785
香川県 678 700 733 749 730 864 946 944 919 901 908 961 1000 1023 1023 1027 1023 1012 996
愛媛県 1047 1096 1142 1165 1179 1361 1522 1541 1501 1446 1418 1465 1507 1530 1515 1507 1493 1468 1431
高知県 671 687 718 715 709 776 874 883 855 813 787 808 831 840 825 817 814 796 764
福岡県 2188 2302 2527 2756 3094 2747 3530 3860 4007 3965 4027 4293 4553 4719 4811 4933 5016 5050 5072
佐賀県 674 685 692 686 702 830 945 974 943 872 838 838 866 880 878 884 877 866 850
長崎県 1136 1164 1233 1297 1370 1319 1645 1748 1760 1641 1570 1572 1591 1594 1563 1545 1517 1479 1427
熊本県 1233 1296 1354 1387 1368 1556 1828 1896 1856 1771 1700 1715 1790 1838 1840 1860 1859 1842 1817
大分県 860 915 946 980 973 1125 1253 1277 1240 1187 1156 1190 1229 1250 1237 1231 1221 1210 1197
宮崎県 651 691 760 824 840 914 1091 1139 1135 1081 1051 1085 1152 1176 1169 1176 1170 1153 1135
鹿児島県 1416 1472 1557 1591 1589 1538 1804 2044 1963 1854 1729 1724 1785 1819 1798 1794 1786 1753 1706
沖縄県 572 558 578 592 575 575 915 801 883 934 945 1043 1107 1179 1222 1273 1318 1362 1393
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<title>人口マップ</title>
</head>
<body>
<div class="container"></div>
<script type="text/javascript">
var mapfilepath = '/sugi2000/raw/560f664f9b32a17b2c4e/japan.topojson';
//var mapfilepath = 'japan.topojson';
var csvpath = 'aaa.csv';
var jinkouData;
var years;
var currentYear;
var zoom = d3.behavior.zoom()
.scaleExtent([1, 8])
.on("zoom", zoomed);
var w = 960;
var h = 960;
var container = d3.select('.container');
var svg = container.append('svg')
.attr('width', w)
.attr('height', h)
.append("g");
var g = svg.append("g");
svg.call(zoom)
.call(zoom.event);
// データの数値から色に変換する関数
var color = d3.scale.linear()
.domain([0,500,1000, 2000,3000, 4000,5000, 6000,7000, 8000,9000,10000,11000,12000,13000,14000])
.range(['#0000FF','#0066FF', '#0099FF', '#00FFFF','#00FF99', '#00FF66', '#00FF00','#66FF00','#99FF00','#CCFF00','#FFFF00','#FFCC00','#FF9900','#FF6600','#FF3300','#FF0000']);
// 全国の都道府県の色を更新する関数
var updateColor = function() {
// 年ラベルの色を更新する
svg.selectAll('text.year')
.transition()
.duration(300)
.style('fill', function() {
var self = d3.select(this);
if (currentYear === self.attr('year')) {
return 'red';
} else {
return 'black';
}
});
// 都道府県の色を更新する
g.selectAll('path')
.transition()
.duration(300)
.style('fill', function() {
return color(d3.select(this).attr('year-' + currentYear));
});
};
// 凡例を追加
svg.selectAll('rect.legend')
.data([0,500,1000, 2000,3000, 4000,5000, 6000,7000, 8000,9000,10000,11000,12000,13000,14000])
.enter()
.append('rect')
.attr('class', 'legend')
.attr('x', 40)
.attr('y', function(d, i) { return 40 + 20 * i; })
.attr('width', 20)
.attr('height', 20)
.attr('fill', function(d) { return color(d); });
svg.selectAll('text.legend')
.data([0,500,1000, 2000,3000, 4000,5000, 6000,7000, 8000,9000,10000,11000,12000,13000,14000])
.enter()
.append('text')
.attr('x', 62)
.attr('y', function(d, i) { return 40 + 20 * i + 12; })
.attr('font-size', 9)
.text(function(d) { return d + '千人'; });
// csvファイルの読み込み
d3.csv(csvpath, function(error, dataset) {
// 背景色
g.append('rect')
.attr('class', 'background')
.attr('x', - w * 2)
.attr('y', - h * 2)
.attr('width', w * 4)
.attr('height', h * 4)
.attr('fill', 'gray');
console.log(dataset);
jinkouData = dataset;
// 年ラベルの設定
years = Object.keys(dataset[0]);
years.some(function(v, i){
if (v === 'ken') { years.splice(i, 1); }
});
svg.selectAll('text.year')
.data(years)
.enter()
.append('text')
.attr('class', 'year')
.attr('x', function(d, i){return (i + 0.5) * w / years.length;})
.attr('y', 20)
.attr('text-anchor', 'middle')
.attr('font-size', 9)
.attr('font-family', 'Helvetica')
.attr('font-weight', 'bold')
.attr('year', function(d){return d;})
.style('cursor', 'pointer')
.text(function(d){return d + '年';});
// クリックイベントの設定
d3.selectAll('text.year').on('click', function(){
currentYear = this.getAttribute('year');
updateColor();
});
// csvファイルを読み込んだ後にmapファイルを読み込み
d3.json(mapfilepath, loadmapCallback);
});
// mapファイル読み込みのコールバック関数(読み込み終了後に呼び出される)
var loadmapCallback = function(error, collection) {
if (error) {
return console.warn(error);
}
var japan = topojson.feature(collection, collection.objects.japan).features;
// setup map
var projection = d3.geo.mercator()
.scale(1500)
.center([137, 34])
//.center(d3.geo.centroid(collection))
.translate([w / 2, h / 2 - 50]);
var path = d3.geo.path().projection(projection);
g.selectAll('path')
.data(japan)
.enter()
.append('path')
.attr('d', path)
.attr('ken', function(d) {
return d.properties.name_local;
})
//.attr('KENCODE', function(d, i) {
// return i;
//})
.style('fill', function(d, i) {
return 'lightgray';
})
.style('cursor', 'pointer')
.on('mouseover', function(){
var self = d3.select(this);
self.style('fill', 'red');
})
.on('mouseout', function(d, i){
var self = d3.select(this);
self.transition()
.duration(300)
.style('fill', function(d, i) {
return color(self.attr('year-' + currentYear));
});
})
;
// jinkouDataの各年のデータをpathの属性に追加する
svg.selectAll('path')
.each(function() {
var p = d3.select(this);
var ds = jinkouData.filter(function(d){
//console.log('ken', d['ken']);
return (d['ken'] === p.attr('ken'));
});
if (ds.length > 0) {
var d = ds[0];
for (var year of years) {
p.attr('year-' + year, d[year]);
}
}
})
// 最初の年で色を更新する
currentYear = years[0];
updateColor();
};
function zoomed() {
g.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
}
d3.select(self.frameElement).style("height", h + "px");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment