2014年9月26日:過去30日間に発生した地震に関する各種ヒストグラム-世界全体および日本の状況について


Data Source:U.S. Geological Survey http://earthquake.usgs.gov/earthquakes/feed/v1.0/csv.php

Sys.time()
## [1] "2014-09-26 17:04:45 JST"

Package

library(xts) # http://cran.r-project.org/web/packages/xts/xts.pdf
library(ggplot2) # http://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf
library(gridExtra) #http://cran.r-project.org/web/packages/gridExtra/gridExtra.pdf
library(knitr) # http://cran.r-project.org/web/packages/knitr/knitr.pdf
library(googleVis) # http://cran.r-project.org/web/packages/googleVis/googleVis.pdf
library(xtable)

Read Data

data.location=2 #1:local 2:web
data.file="all_month.csv"
if(data.location==1){
username<-Sys.info()['user']
path01<-paste("C:/Users/",username,"/Desktop/Earthquake_Data/",sep="")
setwd(path01)
dataset<-read.table(file=paste(path01,data.file,sep=""),sep=",",header=T,as.is=T,skip=0)
}else{
dataset<-read.csv(paste("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/",data.file,sep=""),header=T,as.is=T,skip=0) 
}
dataset.j<-dataset[grep("Japan",dataset[,14]),]

Part of Data

head(dataset,1)
##                       time latitude longitude depth  mag magType nst   gap
## 1 2014-09-26T07:57:13.329Z    37.59    -118.8     0 0.37      ml   6 133.8
##    dmin rms net         id                  updated
## 1 0.132  NA  nn nn00461315 2014-09-26T07:58:28.506Z
##                          place       type
## 1 Long Valley area, California earthquake
tail(dataset,1)
##                          time latitude longitude depth mag magType nst gap
## 9058 2014-08-27T08:04:02.850Z     34.3    -116.4 10.42 1.6      ml  44 111
##         dmin  rms net         id                  updated
## 9058 0.04858 0.15  ci ci37261976 2014-08-27T18:55:17.030Z
##                                   place       type
## 9058 20km N of Yucca Valley, California earthquake

Map for Earthquake over magnitude 5.0 in the past 30 days

dataset$latlong<-paste(dataset$latitude,dataset$longitude,sep=":")
dataset$jst<-as.POSIXct(sub("Z","",sub("T"," ",dataset$time)))+3600*9
dataset$info<-paste("Time(UTC)=",dataset$time," , UTC+9=",dataset$jst,", Depth(km)=",dataset$depth,", Mag=",dataset$mag," , MagType=",dataset$magType,", Place=",dataset$place,sep="")
dataset.s<-subset(dataset,5<=dataset[,5])
gMap<-gvisMap(
dataset.s,"latlong","info",
options=list(
showTip=TRUE, 
showLine=TRUE, 
enableScrollWheel=TRUE,
mapType='terrain', #'hybrid','normal','terrain','satellite'
useMapTypeControl=TRUE
)
)
print(gMap,tag="chart")




Number of Earthquakes in the past 30days by Magnitude

  • Ratio(%)=Japan/World*100
region<-c("","Japan","Indonesia","Mexico","Alaska")
mgt<-c(0,1,2.5,4.5,5.5)
Ecount<-matrix(nrow=length(mgt),ncol=length(region))
for(rrr in 1:length(region)){
r.dataset<-dataset[grep(region[rrr],dataset[,14]),]
for(mmm in 1:length(mgt)){
count<-length(subset(r.dataset,mgt[mmm]<=r.dataset[,5])[,1])
Ecount[mmm,rrr]<-count
}
}
Ecount<-as.data.frame(Ecount,stringsAsFactors=F)
rownames(Ecount)<-paste("over",mgt,sep="")
rownames(Ecount)[1]<-"All"
colnames(Ecount)<-region
colnames(Ecount)[1]<-"World"
Ratio<-signif(Ecount$Japan/Ecount$World*100,digits=2)
Ecount<-cbind(Ecount,Ratio)
Ecount<-Ecount[,c(1,2,6,3,4,5)]
print(xtable(Ecount),type="html")


World Japan Ratio Indonesia Mexico Alaska
All 9023 42 0.47 58 60 3307
over1 5784 42 0.73 58 60 2349
over2.5 1213 42 3.50 58 29 232
over4.5 394 36 9.10 47 12 8
over5.5 26 2 7.70 5 1 1

Histogram

bw=c(5,5,10,0.1)
for(rrr in 1:length(region)){
r.dataset<-dataset[grep(region[rrr],dataset[,14]),]
if(rrr==1){PlotTitle<-"World"}else{PlotTitle<-region[rrr]}
for(ppp in 1:4){ 
switch(ppp,
g<-ggplot(r.dataset,aes(x=latitude)),
g<-ggplot(r.dataset,aes(x=longitude)),
g<-ggplot(r.dataset,aes(x=depth)),
g<-ggplot(r.dataset,aes(x=mag))
)  
g<-g+geom_histogram(alpha=0.2,binwidth=bw[ppp],colour="blue")
g<-g+labs(title=PlotTitle)
g<-g+theme(plot.title=element_text(size=9))
g<-g+theme(axis.title.x=element_text(size=9),axis.title.y=element_text(size=9)) 
g<-g+theme(axis.text.x=element_text(size=9),axis.text.y=element_text(size=9)) 
switch(ppp,
lat<-g,
lon<-g,
dep<-g,
magn<-g
)
}
grid.arrange(lat,lon,dep,magn,nrow=1,ncol=4)
}

plot of chunk unnamed-chunk-7plot of chunk unnamed-chunk-7plot of chunk unnamed-chunk-7plot of chunk unnamed-chunk-7plot of chunk unnamed-chunk-7

Latest Earthquake

print(dataset[,18][1])
## [1] "Time(UTC)=2014-09-26T07:57:13.329Z , UTC+9=2014-09-26 16:57:13, Depth(km)=0, Mag=0.37 , MagType=ml, Place=Long Valley area, California"

Maximum Magnitude Earth Quake in the past 30 days

row.id<-which(max(dataset[,5])==dataset[,5])
print(dataset[,18][row.id])
## [1] "Time(UTC)=2014-09-17T06:14:46.200Z , UTC+9=2014-09-17 15:14:46, Depth(km)=136.7, Mag=6.7 , MagType=mwc, Place=45km NW of Piti Village, Guam"