2014年9月22日:過去30日間に日本で発生した地震の3Dマップ:マグニチュード


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

Sys.time()
## [1] "2014-09-22 21:22:32 JST"

Package

#install.packages("scatterplot3d", dependencies=T)
#install.packages("lattice", dependencies=T)
#install.packages("rgl", dependencies=T)
#install.packages("knitr", dependencies=T)
#install.packages("maps", dependencies=T)
#install.packages("ggplot2", dependencies=T)
library(scatterplot3d) # http://cran.r-project.org/web/packages/scatterplot3d/vignettes/s3d.pdf
library(lattice)
library(rgl)
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

Read Data

data.location=2 #1:local 2:web
data.file="all_month.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) 
}

Part of Data

head(dataset,2)
##                       time latitude longitude depth  mag magType nst gap
## 1 2014-09-22T11:20:49.490Z    36.31    -120.9  4.88 1.60      md  10 100
## 2 2014-09-22T11:10:36.080Z    38.82    -122.8  4.03 1.85      md  39  33
##      dmin  rms net         id                  updated
## 1 0.03471 0.06  nc nc72303701 2014-09-22T12:04:07.166Z
## 2 0.01034 0.02  nc nc72303691 2014-09-22T12:04:02.146Z
##                               place       type
## 1 24km ENE of King City, California earthquake
## 2 5km NW of The Geysers, California earthquake
tail(dataset,2)
##                          time latitude longitude depth mag magType nst gap
## 8608 2014-08-23T12:24:14.000Z    60.12    -141.2   0.3 1.4      ml  NA  NA
## 8609 2014-08-23T12:18:13.000Z    64.72    -149.0  11.6 0.4      ml  NA  NA
##      dmin  rms net         id                  updated
## 8608   NA 0.92  ak ak11365466 2014-08-23T12:50:15.617Z
## 8609   NA 0.48  ak ak11365465 2014-09-04T21:32:20.671Z
##                                 place       type
## 8608  66km E of Cape Yakataga, Alaska earthquake
## 8609 17km NNE of North Nenana, Alaska earthquake

3Dplot

iii<-2
if(iii==2){
dataset<-dataset[grep("Japan",dataset[,14]),]
text<-"Only Japan"
lon.range<-c(120,150)
lat.range<-c(20,60)
}else{
text<-"Entire World"
lon.range<-c(-180,180)
lat.range<-c(-90,90)
}
Latitude.degree<-dataset$latitude
Longitude.degree<-dataset$longitude
Depth.km<-(-1)*dataset$depth
Magnitude<-dataset$mag
ang<-c(110) # angle
z.border<-3
z.min<-max(floor(min(Magnitude)),z.border)
z.max<-max(Magnitude)
ddd<-1
map2d<-map(xlim=c(lon.range[1],lon.range[2]),ylim=c(lat.range[1],lat.range[2]))
map2d<-as.data.frame(map2d[c("x","y")])
map2d<-cbind(map2d,z=z.min)
ppp<-1
for(ccc in 1:length(map2d[,1])){
if(is.na(map2d[,1][ccc])==T){
point.y=map2d$y[ppp:ccc-1]
point.x=map2d$x[ppp:ccc-1]
point.z=map2d$z[ppp:ccc-1]
map.line<-scatterplot3d(y=point.y,x=point.x,z=point.z,angle=ang[ddd],lwd="2",type="l",scale.y=1,color=2,xlim=c(lon.range[1],lon.range[2]),ylim=c(lat.range[1],lat.range[2]),zlim=c(z.min,z.max),xlab="",ylab="",zlab="",x.ticklabs="",y.ticklabs="",z.ticklabs="")
ppp<-ccc
par(new=T)
gc()
gc()
}
}
earthquake.point<-scatterplot3d(y=Latitude.degree,x=Longitude.degree,z=Magnitude,angle=ang[ddd],type="h",lwd="3",scale.y=1,color=4,main=paste(text,"-in the past 30days-Magnitude-over",z.border,sep=""),xlim=c(lon.range[1],lon.range[2]),ylim=c(lat.range[1],lat.range[2]),zlim=c(z.min,z.max),pch=" ")

plot of chunk unnamed-chunk-6

head(dataset,2)
##                         time latitude longitude depth mag magType nst gap
## 32  2014-09-22T07:13:38.460Z    31.50     142.0  10.0 4.7      mb  NA 122
## 133 2014-09-21T17:32:04.940Z    27.92     139.6 491.1 5.2      mb  NA  27
##      dmin  rms net         id                  updated
## 32  2.436 0.87  us usb000sew3 2014-09-22T07:42:09.228Z
## 133 2.399 0.68  us usb000sesb 2014-09-22T01:34:46.628Z
##                                place       type
## 32   269km SE of Hachijo-jima, Japan earthquake
## 133 270km WNW of Chichi-shima, Japan earthquake
tail(dataset,2)
##                          time latitude longitude depth mag magType nst gap
## 8326 2014-08-24T08:26:51.430Z    36.00     139.8 82.22 4.7      mb  NA 116
## 8514 2014-08-23T18:01:55.830Z    27.47     143.0 26.40 4.6      mb  NA 144
##       dmin  rms net         id                  updated
## 8326 1.417 0.73  us usb000s5tb 2014-08-25T06:17:39.228Z
## 8514 0.809 0.49  us usb000s5q7 2014-08-26T16:30:51.509Z
##                                place       type
## 8326      7km ENE of Kasukabe, Japan earthquake
## 8514 87km ENE of Chichi-shima, Japan earthquake