LoginSignup
0
2

More than 1 year has passed since last update.

全国の人流オープンデータを取得する

Last updated at Posted at 2022-07-24

こちらにある全国の人流オープンデータ、とても素晴らしいのですが、
全国のデータを取ってくるためには都道府県毎に利用規約に承諾する必要があったり、zipの下にzipがあったり、zipの下は同名fileだったりで、結構使いにくいんですよね。。
自分は敬意を払って全部手動で承認しましたが、面倒な方はseleniumあたりを使うとよいかもです。

で、取得したデータはとりあえず同じフォルダにおいて、

unzipall.ps1
$f0 = '.\monthly_fromto_city_mesh1km';
for ($p=1; $p -lt 48; $p++){
  $s1 = $f0+'\monthly_fromto_city_'+$p.ToString("00")+'.zip '+$f0+' -Force';
  powershell Expand-Archive $s1;
  Write-Output ($s1);
}
for ($y=2019; $y -lt 2022; $y++){
  for ($m=1; $m -lt 13; $m++){
    for ($p=1; $p -lt 48; $p++){
      $f1= $f0+'\'+$p.ToString("00")+'\'+$y.ToString("00")+'\'+$m.ToString("00");
      $s1 = $f1+'\monthly_fromto_city.csv.zip '+$f1+' -Force';
      powershell Expand-Archive $s1;
      Write-Output ($s1);
    }
  }
}

こんな感じで展開しました(再帰展開の方法がありそうですが見つけられませんでした。。)。
また、実行前に Set-ExecutionPolicy RemoteSigned が必要な場合があります。
その場合は実行後に Set-ExecutionPolicy Restricted で戻しておいたほうが良いかもしれません。

これをmapboxに全部食べさせてクラスター表示してみたものがこちらになります。
結構なデータ量なのですが、ちゃんとクラスターサイズを動的に変更してくれるのがすごいです。。
image.png
image.png
image.png

0
2
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
0
2