2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

e-Statからの人口メッシュデータダウンロード

Last updated at Posted at 2019-01-20

#背景とか
人口メッシュデータが欲しかったので、eStatのメッシュデータを見に行きました。(https://www.e-stat.go.jp/gis/statmap-search?type=1)
で、ダウンロードのためにボタンを一つ一つクリックするのが面倒くさかったので、curlで実装。

一番面倒くさかったのは、地域メッシュ情報を抜き出すところだったと思う。ここは手実行しか思いつかなかった。。。
抜け漏れあるかもしれないので、漏れてたら指摘ください。
↓のサイトの数字を見ながら抜き出し。。。
(https://www.e-stat.go.jp/sites/default/files/pdf/gis/primary_mesh_jouhou.pdf)

あと、離島については、一次メッシュ情報は定義されているものの、データがないらしくってzipの中身がエラーになるようなので、そこはご承知ください。

#実行環境
macOS Mojave(10.14.2)のbashで実施

#コマンド
下記コマンドは、2015年国税調査 => 4次メッシュ(500mメッシュ) => その1 人口等基本集計に関する事項、を落とすように作っています。
他の情報が欲しい場合は、ダウンロードボタンのURL確認してアレンジしてください。

あと、1つダウンロードするごとに5秒sleepにしてます。
まぁ、気長にやってください。


array=("6840" "6841" "6842" "6847" "6848" "6740" "6741" "6742" "6747" "6748" "6641" "6642" "6643" "6644" "6645" "6646" "6647" "6540" "6541" "6542" "6543" "6544" "6545" "6546" "6439" "6440" "6441" "6442" "6443" "6444" "6445" "6339" "6340" "6341" "6342" "6343" "6239" "6240" "6241" "6243" "6139" "6140" "6141" "6039" "6040" "6041" "5939" "5940" "5941" "5942" "5839" "5840" "5841" "5738" "5739" "5740" "5741" "5636" "5637" "5638" "5639" "5640" "5641" "5531" "5536" "5537" "5538" "5539" "5540" "5541" "5432" "5433" "5435" "5436" "5437" "5438" "5439" "5440" "5332" "5333" "5334" "5335" "5336" "5337" "5338" "5339" "5340" "5229" "5231" "5232" "5233" "5234" "5235" "5236" "5237" "5238" "5239" "5240" "5129" "5130" "5131" "5132" "5133" "5134" "5135" "5136" "5137" "5138" "5139" "5029" "5030" "5031" "5032" "5033" "5034" "5035" "5036" "5038" "5039" "4928" "4929" "4930" "4931" "4932" "4933" "4934" "4939" "4828" "4829" "4830" "4831" "4839" "4728" "4729" "4730" "4731" "4739" "4740" "4629" "4630" "4631" "4529" "4530" "4531" "4540" "4429" "4440" "4328" "4329" "4229" "4230" "4128" "4129" "4142" "4027" "4028" "4040" "4042" "3926" "3927" "3928" "3942" "3823" "3824" "3831" "3841" "3724" "3725" "3741" "3622" "3623" "3624" "3631" "3641" "3653" "3036")

i=0
for e in ${array[@]}; do
    echo "array[$i] = ${e}"
	curl "https://www.e-stat.go.jp/gis/statmap-search/data?statsId=T000847&code=${e}&downloadType=2" --output "$HOME/Documents/${e}.zip"
	sleep 5
    let i++
done

#参考文献
https://qiita.com/b4b4r07/items/e56a8e3471fb45df2f59

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?