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


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

Sys.time()
## [1] "2014-09-25 14:30:36 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-25T04:28:20.640Z    38.83    -122.8  1.91 0.34      md   8 172
##      dmin  rms net         id                  updated
## 1 0.01304 0.01  nc nc72305766 2014-09-25T04:46:06.657Z
##                       place       type
## 1 6km W of Cobb, California earthquake
tail(dataset,1)
##                          time latitude longitude depth  mag magType nst
## 8653 2014-08-26T05:26:05.610Z    40.76    -111.6 14.47 1.36      ml  23
##      gap   dmin  rms net         id                  updated
## 8653  53 0.1807 0.15  uu uu60082657 2014-08-26T15:30:51.750Z
##                            place       type
## 8653 2km NW of Summit Park, Utah 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 8618 43 0.50 59 61 3292
over1 5507 43 0.78 59 61 2337
over2.5 1189 43 3.60 59 30 230
over4.5 389 36 9.30 46 12 8
over5.5 26 2 7.70 5 1 0

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-25T04:28:20.640Z , UTC+9=2014-09-25 13:28:20, Depth(km)=1.91, Mag=0.34 , MagType=md, Place=6km W of Cobb, 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"