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


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

Sys.time()
## [1] "2014-09-23 19:50:35 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

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
## 216 2014-09-22T07:13:38.460Z     31.5       142    10 4.7      mb  NA 122
##      dmin  rms net         id                  updated
## 216 2.436 0.87  us usb000sew3 2014-09-22T15:16:05.594Z
##                               place       type
## 216 269km SE of Hachijo-jima, Japan earthquake
tail(dataset.j,1)
##                          time latitude longitude depth mag magType nst gap
## 1061 2014-09-17T23:18:55.340Z    24.84     125.4 41.73 5.4      mb  NA  35
##       dmin  rms net         id                  updated
## 1061 2.191 1.07  us usb000sdrs 2014-09-18T07:21:23.983Z
##                          place       type
## 1061 11km ENE of Hirara, 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
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")