#install.packages("mapproj") #install.packages("ggmap")
#install.packages("DeducerSpatial") #install.packages("leaflet")
dfv = read.csv("volcano.csv", header=TRUE) # volcano data
dfqb = read.csv("quakes_past_10_year_gt_60.csv", header=TRUE) #quake data
we analyze following relationship
library(geosphere)
library(ggplot2)
library(leaflet)
library(gridExtra)
library(data.table)
dfqb$depthColor = cut(dfqb$depth, seq(from = min(dfqb$depth)-1, to = max(dfqb$depth)+1,
length.out= 4))
dfqb$magfact = cut(dfqb$mag, seq(from = min(dfqb$mag)-1, to = max(dfqb$mag)+1,
length.out= 3))
levels(dfqb$magfact) = c("green", "blue")
p1 = ggplot(dfqb) + geom_point(aes(x=longitude,y=mag,color=dfqb$depthColor))
p2 = ggplot(dfqb) + geom_point(aes(x=latitude,y=mag,color=dfqb$depthColor))
dfqb$distHaversinedistfrom00 = distHaversine(matrix(c(dfqb$longitude,
dfqb$latitude),ncol=2),
matrix(c(rep(0,each=length(dfqb$longitude)), rep(0,each=length(dfqb$longitude))), ncol = 2))
p3 = ggplot(dfqb) + geom_point(aes(x=distHaversinedistfrom00,y=mag))
grid.arrange(p1,p2,p3,ncol=1)
# Leaflet map
leaflet(dfqb) %>%
addTiles() %>%
addCircleMarkers(lat=dfqb$latitude, lng=dfqb$longitude, popup=dfqb$time,
fillOpacity = 0.1,color= dfqb$magfact,weight = 3, radius=2) %>%
addCircleMarkers(lat=dfv$Latitude, lng=dfv$Longitude, weight = 3, radius=2,
popup=dfv$VolcanoName,color="red", stroke = FALSE, fillOpacity = 0.8) %>%
addLegend("bottomright", colors =c("red", "green", "blue"),labels=
c("Volcanoes", "Less Intensity quake","High Intensity quakes"),title= "volcanoes vs quakes",opacity = 1)
volcanoes data
earthquake data