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



Histogram of Latitude,Longitude,Depth and Magnitude for All Earthquakes in the past 30 Days


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

Sys.time()
## [1] "2014-09-18 17:11:34 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

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/R_Data_Read/",sep="")
setwd(path01)
dataset<-read.table(file=paste(path01,data.file,sep=""),header=TRUE,sep=",")
}else{
dataset<-read.csv(paste("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/",data.file,sep="")) 
}
dataset.j<-dataset[grep("Japan",dataset[,14]),]

Part of Data

head(dataset,1)
##                       time latitude longitude depth mag magType nst gap
## 1 2014-09-18T07:45:23.200Z    38.81    -122.8   3.5 0.5      Md  12  72
##   dmin  rms net         id                  updated
## 1    0 0.02  nc nc72301521 2014-09-18T07:47:00.498Z
##                               place       type
## 1 4km NW of The Geysers, California earthquake
tail(dataset,1)
##                          time latitude longitude depth  mag magType nst
## 8982 2014-08-19T08:03:38.926Z    41.86    -119.6  1.37 3.02      ml   6
##        gap dmin    rms net         id                  updated
## 8982 105.2  0.5 0.1199  nn nn00456464 2014-09-07T06:26:31.256Z
##                             place       type
## 8982 69km ESE of Lakeview, Oregon earthquake

Map for Earthquake over magnitude 5.0 in the past 30 days

dataset.s<-subset(dataset,5<=dataset[,5])
dataset.s$latlong<-paste(dataset.s$latitude,dataset.s$longitude,sep=":")
dataset.s$jst<-as.POSIXct(sub("Z","",sub("T"," ",dataset.s$time)))+3600*9
dataset.s$info<-paste("Time(UTC)=",dataset.s$time," , UTC+9=",dataset.s$jst,", Depth(km)=",dataset.s$depth,", Mag=",dataset.s$mag," , MagType=",dataset.s$magType,", Place=",dataset.s$place,sep=" ")
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)
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)]
kable(Ecount)
WorldJapanRatioIndonesiaMexicoAlaska
All8922450.5056673603
over15907450.7656672584
over2.51269453.505634292
over4.5391369.20431110
over5.53126.50410

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