Created
March 19, 2016 08:23
-
-
Save jarvisc1/95c095f7bd5055732e46 to your computer and use it in GitHub Desktop.
PintOfScienceMap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This is the server logic of a Shiny web application. You can run the | |
# application by clicking 'Run App' above. | |
# | |
# Find out more about building applications with Shiny here: | |
# | |
# http://shiny.rstudio.com/ | |
# | |
library(shiny) | |
library(rgdal) | |
route <- readOGR("test.gpx", layer = "tracks") | |
# By default, the file size limit is 5MB. It can be changed by | |
# setting this option. Here we'll raise limit to 9MB. | |
options(shiny.maxRequestSize = 9*1024^2) | |
shinyServer(function(input, output){ | |
# filedata <- reactive({ | |
# inFile <- input$file1 | |
# if (is.null(inFile)) { | |
# # User has not uploaded a file yet | |
# return(NULL) | |
# } | |
# #read.csv(inFile$datapath) | |
# readOGR(inFile$datapath, layer = "tracks") | |
# }) | |
filedata <- function(){ | |
inFile <- input$file1 | |
if (is.null(inFile)) { | |
# User has not uploaded a file yet | |
return(NULL) | |
} | |
#read.csv(inFile$datapath) | |
xx <- readOGR(inFile$datapath, layer = "tracks") | |
return(plot(xx)) | |
} | |
output$contents <- renderPlot({ | |
inFile <- input$file1 | |
if (is.null(inFile)) { | |
# User has not uploaded a file yet | |
return(NULL) | |
} | |
filedata() | |
}) | |
output$dplot <- downloadHandler( | |
filename = "map.pdf", | |
content = function(file) { | |
pdf(file) | |
filedata() | |
dev.off() | |
}) | |
# | |
# output$contents <- renderTable({ | |
# # input$file1 will be NULL initially. After the user selects | |
# # and uploads a file, it will be a data frame with 'name', | |
# # 'size', 'type', and 'datapath' columns. The 'datapath' | |
# # column will contain the local filenames where the data can | |
# # be found. | |
# print(inFile$datapath) | |
# | |
# route <- readOGR("test.gpx", layer = "tracks") | |
# # xx@data | |
# | |
# print(route) | |
# }) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This is the user-interface definition of a Shiny web application. You can | |
# run the application by clicking 'Run App' above. | |
# | |
# Find out more about building applications with Shiny here: | |
# | |
# http://shiny.rstudio.com/ | |
# | |
library(shiny) | |
library(rgdal) | |
shinyUI(fluidPage( | |
titlePanel("Uploading Files"), | |
sidebarLayout( | |
sidebarPanel( | |
fileInput('file1', 'Choose file to upload', | |
accept = c( | |
'.gpx', | |
'.csv' | |
) | |
) | |
), | |
mainPanel( | |
plotOutput('contents'), | |
downloadButton('dplot', 'Download') | |
) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment