library(RCurl) library(mapdata) library(xts) # lon=c(-180,180) lat=c(-90,90) # minmagnitude<-5 # #一括処理(USGS:地震データダウンロード。保存。) #震源データをダウンロードする年 start<-1923 ; end<-2016 library(RCurl) for (i in start:end){ year<-as.character(i) #format=csvとする url<-paste0("http://earthquake.usgs.gov/fdsnws/event/1/query?format=csv&starttime=",as.numeric(year),"-01-01&endtime=",as.numeric(year)+1, "-01-01&minmagnitude=",minmagnitude,"&minlatitude=",lat[1],"&maxlatitude=",lat[2],"&minlongitude=",lon[1],"&maxlongitude=",lon[2],"&eventtype=earthquake") doc <- getURL(url) filename<-paste0("USGS",year,"_",lon[1],"_",lon[2],"_",lat[1],"_",lat[2],".csv") out <- file(filename, "w") # 書き込みモードで開く writeLines(doc,out,sep = "\n") close(out) } # #eq eq<-read.table(text="",col.names=c("time","latitude","longitude","depth","mag")) for (i in start:end){ year<-as.character(i) filename<-paste0("USGS",year,"_",lon[1],"_",lon[2],"_",lat[1],"_",lat[2],".csv") tmp<-read.csv(filename) #eqdata <- subset(tmp, select=c(time,latitude,longitude,depth,mag,nst,gap,dmin,rms)) tmp <- subset(tmp, select=c(time,latitude,longitude,depth,mag)) eq<-rbind(eq,tmp) } # #save(eq,file="usgs5_1923_20161126.RData") # #USGS:地震データ eqdata <- subset(eq, select=c(time,longitude,latitude,depth,mag)) #head(eqdata) eqdata$time<-gsub("T"," ",substring(eqdata[,1],1,19)) eq.xts<-as.xts(read.zoo(eqdata)) ymd<-"1923-01-01::2016-11-26" eqdata<-data.frame(coredata(eq.xts[ymd])) # #震源の深さ # depth<10km eqdata1<-subset(eqdata,depth<10) eqdata1$depth_rank<-" 10km 未満" eqdata1$col<-"red" # 10<=depth<20 eqdata2<-subset(eqdata,depth>=10 & depth<20) eqdata2$depth_rank<-" 10km以上20km未満" eqdata2$col<-"orange" # 20<=depth<40 eqdata3<-subset(eqdata,depth>=20 & depth<40) eqdata3$depth_rank<-" 20km以上40km未満" eqdata3$col<-"gold4" # 40<=depth<80 eqdata4<-subset(eqdata,depth>=40 & depth<80) eqdata4$depth_rank<-" 40km以上80km未満" eqdata4$col<-"green" # 80<=depth<150 eqdata5<-subset(eqdata,depth>=80 & depth<150) eqdata5$depth_rank<-" 80km以上150km未満" eqdata5$col<-"blue" # 150<=depth eqdata6<-subset(eqdata,depth>=150) eqdata6$depth_rank<-"150km以上" eqdata6$col<-"purple" # eq<-rbind(eqdata1,eqdata2,eqdata3,eqdata4,eqdata5,eqdata6) #並べ替え:マグニチュードの昇順 sortlist <- order(eq$mag) subeq<- eq[sortlist,] ## # par(family = "TakaoExMincho") #png("world1923_20161126.png",width=1000,height=800) map('world',fill=T,col="gray95",mar = c(5,4,4,15)) #map('worldHires',fill=T,col="gray95",mar = c(5,4,4,15)) points(subeq$longitude,subeq$latitude,cex=subeq$mag/15,col=adjustcolor(subeq$col,1),pch=19) par(xpd=T) # cexsize=c(5,7,9)/15 legend(par("usr")[2]*1.001,par("usr")[3]*0.05+par("usr")[4]*0.95,title="Magnitude", legend = c("M=5","M=7","M=9"), col=1,pch=19,pt.cex=cexsize, cex =1, x.intersp = 2, y.intersp =1.8,bty = "n") # legend(par("usr")[2],par("usr")[3]*0.6+par("usr")[4]*0.4,title="Depth", legend = c("D<10km","10km<=D<20km","20km<=D<40km","40km<=D<80km","80km<=D<150km","150km<=D"), cex=1,pch=19,col=c("red","orange","gold4","green","blue","purple"), pt.cex =1.5,bg ="gray90", x.intersp = 1, y.intersp =1.2,bty = "n") par(xpd=F) title(paste0(ymd," 地震 M>=5 ( 地震データ:USGS )")) map.axes(cex.axis=0.8,las=1) #dev.off()
|