Я новичок в Shinny и хотел бы выполнить простую задачу:
- ввести шейп-файл с моего компьютера
- открыть его с помощью листовки или карты.
Но я получаю сообщение "Warning: Error in ogrListLayers: Cannot open data source
"
Ниже приведены коды:
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)
Тойдата:
#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")