隕石落下データを地図上に描画してみる

kaggleのデータセット一覧を見ていたら、Meteorite-landingというものを見つけました。
Meteorite Landings | Kaggle
別に、地質学とか天文学とかに詳しいわけではないのですが面白いデータだと感じたのでRでできるようになったことを織り交ぜながら可視化して見たいなと思ったのでやって見ます。

library(ggplot2)
library(dplyr)
mtl <- read.csv("meteorite-landings.csv")
str(mtl)
'data.frame':    45716 obs. of  10 variables:
 $ name       : Factor w/ 45716 levels "Aachen","Aarhus",..: 1 2 6 10 406 417 429 430 435 454 ...
 $ id         : int  1 2 6 10 370 379 390 392 398 417 ...
 $ nametype   : Factor w/ 2 levels "Relict","Valid": 2 2 2 2 2 2 2 2 2 2 ...
 $ recclass   : Factor w/ 466 levels "Acapulcoite",..: 333 197 85 1 339 85 360 190 339 242 ...
 $ mass       : num  21 720 107000 1914 780 ...
 $ fall       : Factor w/ 2 levels "Fell","Found": 1 1 1 1 1 1 1 1 1 1 ...
 $ year       : int  1880 1951 1952 1976 1902 1919 1949 1814 1930 1920 ...
 $ reclat     : num  50.8 56.2 54.2 16.9 -33.2 ...
 $ reclong    : num  6.08 10.23 -113 -99.9 -64.95 ...
 $ GeoLocation: Factor w/ 17101 levels "","(-1.002780, 37.150280)",..: 16779 16983 16923 9106 844 14808 16496 16453 784 721 …
head(mtl,2)
    name id nametype recclass mass fall year   reclat  reclong            GeoLocation
1 Aachen  1    Valid       L5   21 Fell 1880 50.77500  6.08333  (50.775000, 6.083330)
2 Aarhus  2    Valid       H6  720 Fell 1951 56.18333 10.23333 (56.183330, 10.233330)

整然データになっているようですし、落下地点が緯度経度で載っているいるのでとても扱いやすそうです。
というか、mass(大きさ)ってどのくらいなのでしょうか?
引用元によると隕石の大きさをグラムで表しているみたいです。

mass:the mass of the meteorites, in grams

mtl <- select(mtl, -id,-GeoLocation)
ggplot(mtl, aes(x=mass)) + geom_histogram() + xlim(0,40000) + ylim(0,5000)

f:id:kokiando:20170718114825p:plain

ggplot(mtl, aes(x=mass)) + geom_histogram() + xlim(0,10000) + ylim(0,5000)

f:id:kokiando:20170718114927p:plain

ほとんどが数キロくらいの重さなんですね。

それと、データが45,716個もあるみたいなので、今回は少しばかり絞ってみたいと思います。今回は一つの年に絞ってやっていこうと思いますので、yearの最頻値が出てくる年に限定していきます。

statmode <- function(x) {
     names(which.max(table(x)))
 }
(mode <- statmode(mtl$year))
[1] "2003"

2003年のデータが最も多いらしいので絞っていきます。

mtl <- filter(mtl, year==2003)
str(mtl)
'data.frame':    3323 obs. of  8 variables:
 $ name    : Factor w/ 45716 levels "Aachen","Aarhus",..: 4180 15652 15656 16670 16682 25955 30715 30720 30799 384 ...
 $ nametype: Factor w/ 2 levels "Relict","Valid": 2 2 2 2 2 2 2 2 2 2 ...
 $ recclass: Factor w/ 466 levels "Acapulcoite",..: 339 190 197 181 183 190 333 144 333 390 ...
 $ mass    : num  190 414 168 16820 6669 ...
 $ fall    : Factor w/ 2 levels "Fell","Found": 1 1 1 1 1 1 1 1 1 2 ...
 $ year    : int  2003 2003 2003 2003 2003 2003 2003 2003 2003 2003 ...
 $ reclat  : num  17.71 34.45 1.34 29.58 20.46 ...
 $ reclong : num  -11.4 132.4 31.5 77.6 86.7 …

3,323個に絞りました。
次は地図を表示していきます。

world <- map_data(“world”)
map <- ggplot() + geom_polygon(data = world,  aes(x = long, y=lat, group = group), colour = "black", fill ="white")
map

f:id:kokiando:20170718115504p:plain

str(world)
'data.frame':    99338 obs. of  6 variables:
 $ long     : num  -69.9 -69.9 -69.9 -70 -70.1 ...
 $ lat      : num  12.5 12.4 12.4 12.5 12.5 ...
 $ group    : num  1 1 1 1 1 1 1 1 1 1 ...
 $ order    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ region   : chr  "Aruba" "Aruba" "Aruba" "Aruba" ...
 $ subregion: chr  NA NA NA NA ...
map_data <- map + geom_point(data = mtl, aes(x = reclong, y = reclat), colour="Red", fill="Orange",pch=21, size=5, alpha=I(0.7))
map_data

f:id:kokiando:20170718115715p:plain

いちおうこれでデータの可視化はできました。

head(mtl,2)
             name nametype recclass mass fall year   reclat  reclong
1 Boumdeid (2003)    Valid       L6  190 Fell 2003 17.71067 -11.3715
2       Hiroshima    Valid       H5  414 Fell 2003 34.45000 132.3833

二行目に日本がありますね。少しググって見ましょう。
広島隕石 - Wikipedia
でできました。笑
現在は広島市こども文化科学館に展示されてるみたいです。興味がある人は見てきてはいかがですか?
僕は多分行きませんね。笑

P.S.
一年くらい前からボードゲームに少しはまってます。ということでこの前カルカソンヌというものを買ってきました。f:id:kokiando:20170718175757j:plain
想像していた以上に楽しくて結構いい買い物したなと思ってます。何年か前にはドイツボードゲーム大賞もとったらしくさらには世界大会も催されてるみたいです。
f:id:kokiando:20170718175829j:plain
ボードゲームをやってると童心に帰れる一方、戦略を考えれば考えるほど深くなって行くのでみなさんにもおすすめしたいです。