Shiny App Presentation: Solar Sunrise & Sunset around the World from a date

Xavi Jacas
23-1-2015

                   sunrise              sunset
newlon 2015-01-01 05:59:41 2015-01-01 18:07:10

https://xavijacas.shinyapps.io/ShinyApp

Presentation

This Shiny App, Solar Sunrise & Sunset around the World from a date, tries to show the diferences in Time of the Solar events, sunrise, sunset, around the World.

By default the app tries to geolocate de visit, and if is permited, the sunrise and sunset events for that position are show, for the next year since the actual date.

Once that is done, the user can change:

  • Date
  • time period to show (days from today for whom will be calculated the events)
  • Latitud
  • Longitud
  • a button to update de map to see the map part of that part world (by lat/lon)

the graphic shows sunrise and sunset Times for this variables.

UI.R

UI.R code, can be found: https://github.com/existeundelta/ShinyApp/blob/master/ui.R

see the use of:

l
    tags$div(HTML('
       ...       '))

to directly put html in the UI

Server.R

Server.R code, can be found: https://github.com/existeundelta/ShinyApp/blob/master/server.R

the function to get the solar events data, get.sunrise is:

get.sunrise <- function(lat, lon, date, n){
  tmp <- sunrise.set(lat, lon, date, timezone="UTC", num.days = n)  
  solar <- tmp
  solar$sunrise <- POSIXctToHour(tmp[,1]) 
  solar$sunset <- POSIXctToHour(tmp[,2])

  return (solar)
}

using library(StreamMetabolism)

Example, Greenland