Skip to content

Commit

Permalink
Merge pull request #90 from ESHackathon/nonplottable
Browse files Browse the repository at this point in the history
add plotting for points without lat/long
  • Loading branch information
DrMattG authored Apr 13, 2022
2 parents d2314ce + cb4ff19 commit 19570d2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
38 changes: 38 additions & 0 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,24 @@ shinyServer(
lng_plotted <-
as.numeric(unlist(data_active() %>%
dplyr::select(input$map_lng_select)))

# replace missing lat/long with standard locations chosen by 'nonplotted' input
if(input$nonplotted == 'mid Atlantic'){
lat_plotted[is.na(lat_plotted)] <- 0
lng_plotted[is.na(lng_plotted)] <- -20
} else if(input$nonplotted == 'south Pacific'){
lat_plotted[is.na(lat_plotted)] <- -65
lng_plotted[is.na(lng_plotted)] <- -124
} else if(input$nonplotted == 'mid Pacific'){
lat_plotted[is.na(lat_plotted)] <- 0
lng_plotted[is.na(lng_plotted)] <- -165
} else if(input$nonplotted == 'Equator 0 degrees'){
lat_plotted[is.na(lat_plotted)] <- 0
lng_plotted[is.na(lng_plotted)] <- 0
} else if(input$nonplotted == 'Greenland'){
lat_plotted[is.na(lat_plotted)] <- 75
lng_plotted[is.na(lng_plotted)] <- -40
}

if (input$atlas_color_by_select != "") {
color_user <- input$atlas_color_by_select
Expand Down Expand Up @@ -826,6 +844,26 @@ shinyServer(
as.numeric(unlist(data_active() %>%
dplyr::select(input$map_lng_select)))

# replace missing lat/long with standard locations chosen by 'nonplotted' input
if(input$nonplotted == 'mid Atlantic'){
lat_plotted[is.na(lat_plotted)] <- 0
lng_plotted[is.na(lng_plotted)] <- -20
} else if(input$nonplotted == 'south Pacific'){
lat_plotted[is.na(lat_plotted)] <- -65
lng_plotted[is.na(lng_plotted)] <- -124
} else if(input$nonplotted == 'mid Pacific'){
lat_plotted[is.na(lat_plotted)] <- 0
lng_plotted[is.na(lng_plotted)] <- -165
} else if(input$nonplotted == 'Equator 0 degrees'){
lat_plotted[is.na(lat_plotted)] <- 0
lng_plotted[is.na(lng_plotted)] <- 0
} else if(input$nonplotted == 'Greenland'){
lat_plotted[is.na(lat_plotted)] <- 75
lng_plotted[is.na(lng_plotted)] <- -40
}



if (input$atlas_color_by_select != "") {
color_user <- input$atlas_color_by_select
factpal <- colorFactor(RColorBrewer::brewer.pal(9, 'Set1'),
Expand Down
7 changes: 6 additions & 1 deletion ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ body <- dashboardBody(
tabPanel("Configure Map",
wellPanel(fluidRow(
column(2,
uiOutput("map_columns")
uiOutput("map_columns"),
selectInput("nonplotted",
label = "Select where to plot studies without lat/long",
choices = c('mid Atlantic', 'south Pacific', 'mid Pacific', 'Equator 0 degrees', 'Greenland'),
selected = 'mid Atlantic'
)
),
column(4,
uiOutput("atlas_popups"),
Expand Down

0 comments on commit 19570d2

Please sign in to comment.