2014年9月25日 過去1週間内に発生した地震のマグニチュード等 対象地域:日本


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

Sys.time()

[1] “2014-09-25 14:17:48 JST”

Package

library(knitr)
library(maps) # http://cran.r-project.org/web/packages/maps/maps.pdf
library(ggplot2) # http://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf
library(googleVis) # http://cran.r-project.org/web/packages/googleVis/googleVis.pdf
library(geosphere) # http://cran.r-project.org/web/packages/geosphere/geosphere.pdf
library(Imap) # http://cran.r-project.org/web/packages/Imap/Imap.pdf

Read Data

data.location<-2 #1:local 2:web
data.file<-"all_week.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.j,1)
##                         time latitude longitude depth mag magType nst gap
## 115 2014-09-24T13:30:57.380Z    37.56     141.3 56.05 5.1     mww  NA  89
##      dmin  rms net         id                  updated
## 115 0.527 0.77  us usb000sfk5 2014-09-24T19:46:04.000Z
##                        place       type
## 115 30km ENE of Namie, Japan earthquake
tail(dataset.j,1)
##                          time latitude longitude depth mag magType nst gap
## 1465 2014-09-18T12:39:07.680Z    39.53     143.6 15.27 4.5      mb  NA 135
##       dmin  rms net         id                  updated
## 1465 2.498 0.81  us usb000sdxz 2014-09-18T20:42:38.143Z
##                         place       type
## 1465 138km E of Miyako, Japan earthquake

googlevis

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

maps

for(mmm in 1:length(dataset.j[,1])){
tmp<-dataset.j$mag[mmm]+10^-3
if(round(tmp)==floor(tmp)){tmp<-floor(tmp)}else{tmp<-(round(tmp)-0.5)} 
dataset.j$magMap[mmm]<-tmp
}
japan<-map(xlim=c(120,150),ylim=c(20,50))
# http://cran.r-project.org/web/packages/maps/maps.pdf#page=8
str(japan)
## List of 4
##  $ x    : num [1:635] 119 119 119 121 121 ...
##  $ y    : num [1:635] 50 50.3 50.4 52.2 52.5 ...
##  $ range: num [1:4] 120 150 20 50
##  $ names: chr [1:75] "USSR" "China" "North Korea" "South Korea" ...
##  - attr(*, "class")= chr "map"
japan<-as.data.frame(japan[c("x","y")])
japan.map<-ggplot(japan,aes(x,y))
japan.map<-japan.map+geom_path()
# http://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf#page=79
japan.map<-japan.map+geom_point(
data=dataset.j,
aes(
x=longitude,
y=latitude,
size=magMap
)
)
japan.map<-japan.map+scale_size_continuous(paste("Magnitude(M)","\n","M~(M+0.5)"))

Map

  • maps
plot(japan.map)

plot of chunk unnamed-chunk-7

  • google map
print(gMap,tag="chart")




Latest Earthquake

print(dataset.j[,18][1])
## [1] "Time(UTC)=2014-09-24T13:30:57.380Z , UTC+9=2014-09-24 22:30:57, Depth(km)=56.05, Mag=5.1 , MagType=mww, Place=30km ENE of Namie, Japan"

Maximum Magnitude Earthquake in the past 7 days

row.id<-which(max(dataset.j[,5])==dataset.j[,5])
print(dataset.j[,18][row.id])
## [1] "Time(UTC)=2014-09-21T17:32:04.940Z , UTC+9=2014-09-22 02:32:04, Depth(km)=491.12, Mag=5.2 , MagType=mb, Place=270km WNW of Chichi-shima, Japan"

Eepicentral distance and hypocentral distance from max magnitude earthquake point

#lon.1<-readline("Lon : ")
#lat.1<-readline("Lat : ")
lon.1<-139.744858 # e.g. national diet in Japan
lat.1<-35.675888
lon.2<-dataset.j[,3][row.id]
lat.2<-dataset.j[,2][row.id]
#epicentral distance
epi.dis<-gdist(lon.1,lat.1,lon.2,lat.2,units="km",a=6378137.0,b=6356752.3142,verbose=FALSE)
cat("Epicentral distance","\n")
## Epicentral distance
print(epi.dis)
## [1] 859.5
# http://cran.r-project.org/web/packages/Imap/Imap.pdf#page=2
#geocentric latitude
eccentricity<-(6378137^2-6356752.3142^2)^0.5/6378137
e2<-eccentricity^2
lat.1.gl<-atan((1-e2)*tan(lat.1*pi/180))
lat.2.gl<-atan((1-e2)*tan(lat.2*pi/180))
cat("Geocentric latitude","\n")
## Geocentric latitude
print(lat.1.gl*180/pi)
## [1] 35.49
print(lat.2.gl*180/pi)
## [1] 27.77
#hypocentral distance
phi.x<-lat.1.gl
phi.e<-lat.2.gl
lambda.x<-lon.1*pi/180
lambda.e<-lon.2*pi/180
a<-6378.137
d<-dataset.j[,4][row.id]
AE<-cos(phi.e)*cos(lambda.e)*(a-d)/a
BE<-cos(phi.e)*sin(lambda.e)*(a-d)/a
CE<-sin(phi.e)*(a-d)/a
AX<-cos(phi.x)*cos(lambda.x)
BX<-cos(phi.x)*sin(lambda.x)
CX<-sin(phi.x)
delta.s<-((AE-AX)^2+(BE-BX)^2+(CE-CX)^2)^0.5
hyp.dis<-delta.s*a
cat("Hypocentral Distance","\n")
## Hypocentral Distance
print(hyp.dis)
## [1] 960.9



Reference
・正木和明・原徹夫.『 緊急地震速報における震度予測式等ソフトウェアの変更』