From cb4ff19cb7c4db4fb23e7d1c2620cc360de041a5 Mon Sep 17 00:00:00 2001 From: nealhaddaway <43783900+nealhaddaway@users.noreply.github.com> Date: Tue, 12 Apr 2022 19:35:28 +0100 Subject: [PATCH] add plotting for points without lat/long --- server.R | 38 ++++++++++++++++++++++++++++++++++++++ ui.R | 7 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/server.R b/server.R index d480be2..de8d432 100755 --- a/server.R +++ b/server.R @@ -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 @@ -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'), diff --git a/ui.R b/ui.R index 64962a0..faae8d0 100755 --- a/ui.R +++ b/ui.R @@ -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"),