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


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

Sys.time()
## [1] "2014-09-18 15:45:22 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/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.j,3)
##                         time latitude longitude depth mag magType nst gap
## 38  2014-09-17T23:18:55.340Z    24.84     125.4 41.73 5.4      mb  NA  35
## 446 2014-09-16T03:28:31.160Z    36.06     139.9 53.92 5.6      mb  NA  89
## 562 2014-09-15T14:15:31.030Z    42.23     144.9 26.61 4.5      mb  NA 136
##      dmin  rms net         id                  updated
## 38  2.191 1.07  us usb000sdrs 2014-09-17T23:39:46.096Z
## 446 0.305 1.35  us usb000scur 2014-09-17T15:35:30.430Z
## 562 1.329 0.59  us usb000sciv 2014-09-15T22:19:01.810Z
##                          place       type
## 38   11km ENE of Hirara, Japan earthquake
## 446     2km WNW of Iwai, Japan earthquake
## 562 94km SSE of Kushiro, Japan earthquake
tail(dataset.j,3)
##                          time latitude longitude depth mag magType nst gap
## 990  2014-09-13T10:11:50.910Z    27.59     140.0 492.4 4.3      mb  NA  64
## 1136 2014-09-12T17:03:39.820Z    44.42     141.5 250.5 4.5      mb  NA  62
## 1467 2014-09-11T07:30:25.820Z    27.30     140.4 411.6 4.9      mb  NA  54
##       dmin  rms net         id                  updated
## 990  2.007 0.87  us usb000sc3h 2014-09-13T18:14:33.167Z
## 1136 0.849 0.99  us usb000sbus 2014-09-13T16:57:02.273Z
## 1467 1.638 0.72  us usb000sbam 2014-09-11T15:32:51.903Z
##                                 place       type
## 990  226km WNW of Chichi-shima, Japan earthquake
## 1136         55km NNW of Rumoi, Japan earthquake
## 1467   185km W of Chichi-shima, 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,
width=800,
height=800
)
)

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

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




  • maps
plot(japan.map)

plot of chunk unnamed-chunk-8