prep_mapdata: Prepares the data to be mapped directly

Description Usage Value Examples

View source: R/capri_maps.r

Description

Combines .kml data and NUTS2 regional mappings

Usage

1

Value

A tibble with the merged data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
x <- prep_mapdata() %>% left_join(co2em, by = c("CAPRI_NUTS_ID" = "region"))
# remove Portuguese islands and Canarias to remove empty spaces on EU maps...
x <- x %>% filter(!grepl("PT20", CAPRI_NUTS_ID)) %>% filter(!grepl("PT30", CAPRI_NUTS_ID)) %>% filter(!grepl("ES70", CAPRI_NUTS_ID))
# prepare the map with ggplot
p <- x %>% filter(!grepl("TR.*", CAPRI_NUTS_ID)) %>%
  ggplot(aes(longitude, latitude, group = name, fill = pc)) +
  geom_polygon(color = "white") +
  coord_map("albers", lat0=30, lat1=35) +
  scale_fill_gradient(low = "red", high = "white") +
  labs(x = "", y = "") + theme(
    axis.text.x = element_blank(),
    axis.text.y = element_blank(),
    axis.ticks = element_blank())
p$labels$fill <- " "
# save map to .png
p
ggsave("mapout/emission_changes.png", width = 16, height = 9)

trialsolution/caprir documentation built on Dec. 5, 2019, 8:54 a.m.