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

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

Sys.time()
## [1] "2014-09-19 19:29:00 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
## 99 2014-09-18T16:34:48.530Z    38.01     141.9 52.41 4.5      mb  NA 111
##     dmin  rms net         id                  updated
## 99 0.921 0.89  us usb000se0x 2014-09-19T00:41:59.282Z
##                           place       type
## 99 71km SE of Ishinomaki, Japan earthquake
tail(dataset.j,1)
##                          time latitude longitude depth mag magType nst gap
## 1375 2014-09-12T17:03:39.820Z    44.42     141.5 250.5 4.5      mb  NA  62
##       dmin  rms net         id                  updated
## 1375 0.849 0.99  us usb000sbus 2014-09-13T16:57:02.273Z
##                         place       type
## 1375 55km NNW of Rumoi, 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")