Skip to content

Instantly share code, notes, and snippets.

@loiyumba
Created March 30, 2016 05:37
Show Gist options
  • Save loiyumba/ba308734b7346f6b6269e9e4c88e6008 to your computer and use it in GitHub Desktop.
Save loiyumba/ba308734b7346f6b6269e9e4c88e6008 to your computer and use it in GitHub Desktop.
mapping indian subcontinent earthquake
## Major earthquake in Indian Sub-continent
## Load the libraries
library(shiny)
library(leaflet)
# Attach the data
quake_data <- read.csv("india.csv", stringsAsFactors = FALSE)
# UI side
ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%; height:100%}"),
leafletOutput("map", width = "100%", height = "100%"),
absolutePanel(top = 10, right = 2,
h2("Earthquakes in Indian subcontinent"),
selectInput("year", "Select a Year",
unique(quake_data$Year)),
h5("Click on the red dot for info")
)
)
# Server side
server <- function(input, output, session){
output$map <- renderLeaflet({
quake_data <- quake_data[quake_data$Year == input$year, ]
leaflet(quake_data) %>%
addTiles() %>%
setView(lng = 78, lat = 21, zoom = 4) %>%
addCircleMarkers(lng = ~Long ,lat = ~Lat, radius = ~(Magnitude*2), color = "red",
stroke = FALSE, fillOpacity = 0.4, popup = ~paste(sep = " ",
"magnitude-",Magnitude, "Death-",Deaths))
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment