Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make a function for static map output of station results for selected year #8

Closed
fawda123 opened this issue Nov 26, 2019 · 4 comments
Closed

Comments

@fawda123
Copy link
Member

like so:

image

@fawda123
Copy link
Member Author

Need to add basemap to this...

library(ggrepel)
library(sf)
library(ggmap)

data(tbseg)

prj <- '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
yrsel <- 2019

tomap <- epcdata %>% 
  anlz_avedatsite() %>% 
  anlz_attainsite(yrrng = yrsel, thr = 'chla') %>% 
  dplyr::left_join(stations, by = c('epchc_station', 'bay_segment')) %>% 
  mutate(
    trgtmet = factor(trgtmet, levels = c('yes', 'no'), labels = c('yes', 'no'))
  ) %>% 
  st_as_sf(coords = c('Longitude', 'Latitude'), crs = prj)
  


leglab <- paste0('Target met\nin ', yrsel, '?')

seglabs <- data.frame(
  Longitude = c(-82.6, -82.64, -82.59, -82.4),
  Latitude = c(27.55, 27.8, 28, 27.91), 
  bay_segment = c('LTB', 'MTB', 'OTB', 'HB')
  ) %>% 
  st_as_sf(coords = c('Longitude', 'Latitude'), crs = prj)

ggplot() +
  geom_sf(data = tbseg, fill = NA) + 
  geom_sf(data = tomap, aes(colour = trgtmet, fill = trgtmet)) +
  geom_text_repel(data = tomap, aes(label = round(val, 1), geometry = geometry), stat = "sf_coordinates", size = 3) +
  geom_text(data = seglabs, aes(label = bay_segment, geometry = geometry), stat = "sf_coordinates") + 
  scale_fill_manual(leglab,  values = c('red', 'green'), drop = F) +
  scale_colour_manual(leglab, values = c('red', 'green'), drop = F) + 
  theme(
    axis.title = element_blank()
  )

@fawda123
Copy link
Member Author

dc46cc8 Good enough

show_mapsite(epcdata, 2018)

image

@mgm-cincy
Copy link

mgm-cincy commented Nov 30, 2019 via email

@fawda123
Copy link
Member Author

fawda123 commented Dec 1, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants