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


Execution

Sys.time()

[1] “2014-10-03 13:44:41 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(Imap) # http://cran.r-project.org/web/packages/Imap/Imap.pdf
library(geosphere) # http://cran.r-project.org/web/packages/geosphere/geosphere.pdf
library(xts)

Import Raw 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]),]

Prepare for 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
)
)

Prepare for 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)"))

Earthquake Map

  • maps
plot(japan.map)

plot of chunk unnamed-chunk-6

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




Latest Earthquake

print(dataset.j[,18][1])
## [1] "Time(UTC)=2014-10-03T03:21:11.760Z , UTC+9=2014-10-03 12:21:11, Depth(km)=391.27, Mag=4.4 , MagType=mb, Place=Izu Islands, Japan region"

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-10-03T00:57:30.680Z , UTC+9=2014-10-03 09:57:30, Depth(km)=30.85, Mag=5.3 , MagType=mb, Place=89km NE of Miyako, Japan"

Earthquake List

kable(dataset.j[,c(17,5,6,14,2,3,4)])
jstmagmagTypeplacelatitudelongitudedepth
32014-10-03 12:21:114.4mbIzu Islands, Japan region29.85139.3391.27
252014-10-03 09:57:305.3mb89km NE of Miyako, Japan40.17142.730.85
1902014-10-02 14:32:374.6mb34km E of Ishinomaki, Japan38.41141.754.22
4682014-10-01 09:29:184.3mb289km WNW of Chichi-shima, Japan28.32139.6524.07
7412014-09-29 23:55:574.8mbIzu Islands, Japan region29.33140.440.84
8852014-09-29 10:05:404.9mb118km S of Kushiro, Japan41.91144.338.07

Eepicentral distance and hypocentral distance from max magnitude earthquake point

lon.2<-dataset.j[,3][row.id]
lat.2<-dataset.j[,2][row.id]
d<-dataset.j[,4][row.id]
####
lon.1<-139.744858 # e.g. national diet in Japan
lat.1<-35.675888
r.a<-6378.137 #radius km
r.b<-6356.7523142 #radius km
#epicentral distance
epi.dis<-gdist(lon.1,lat.1,lon.2,lat.2,units="km",a=r.a*1000,b=r.b*1000,verbose=FALSE)
# http://cran.r-project.org/web/packages/Imap/Imap.pdf#page=2
#geocentric latitude
eccentricity<-(r.a^2-r.b^2)^0.5/r.a
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))
#hypocentral distance
phi.x<-lat.1.gl
phi.e<-lat.2.gl
lambda.x<-lon.1*pi/180
lambda.e<-lon.2*pi/180
AE<-cos(phi.e)*cos(lambda.e)*(r.a-d)/r.a
BE<-cos(phi.e)*sin(lambda.e)*(r.a-d)/r.a
CE<-sin(phi.e)*(r.a-d)/r.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*r.a
cat("Epicentral distance(km)=",epi.dis)
## Epicentral distance(km)= 564.1
cat("Hypocentral Distance(km)",hyp.dis)
## Hypocentral Distance(km) 564.1
cat("Geocentric latitude(degree):point1=",lat.1.gl*180/pi,", point2=",point2=lat.2.gl*180/pi)
## Geocentric latitude(degree):point1= 35.49 , point2= 39.98
cat("Eccentricity=",eccentricity)
## Eccentricity= 0.08182

Covariate Plot

attach(dataset.j)
coplot(latitude~longitude|mag)

plot of chunk unnamed-chunk-12

nrow(dataset.j)
## [1] 6