Reputation: 146
I would like to do the task of:
But I am getting the message "Warning: Error in ogrListLayers: Cannot open data source
"
Below are the codes:
rm(list=ls())
library(shiny)
library(rgdal)
library(leaflet)
library(mapview)
#### UI ####
ui<-fluidPage(
tabsetPanel(
tabPanel("Input",
fileInput("Map_01", "Shapefile - MAP",
accept = c(".shp","shp"), multiple=FALSE)
),
tabPanel("Map",
mainPanel(
leafletOutput("mapplot")
)
)
)
)
#### SERVER ####
server<-function(input,output){
map <- reactive({
mapview(readOGR(input$Map_01$datapath))
})
output$mapplot <-renderLeaflet({
leaflet(map())
})
}
shinyApp(ui=ui,server=server)
Toydata:
#Download the shapefiles
download.file("http://thematicmapping.org/downloads/TM_WORLD_BORDERS_SIMPL-0.3.zip" ,destfile="world_shape_file.zip")
system("unzip world_shape_file.zip")
inputfile<-readOGR("./TM_WORLD_BORDERS_SIMPL-0.3.shp")
Upvotes: 0
Views: 177