Skip to content

Instantly share code, notes, and snippets.

@agricolamz
Last active July 4, 2021 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agricolamz/13d6add7958df0445cba1b4775e9e256 to your computer and use it in GitHub Desktop.
Save agricolamz/13d6add7958df0445cba1b4775e9e256 to your computer and use it in GitHub Desktop.
# by G. Moroz
# License: GPL-2
library(tidyverse)
wind_turbine <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-10-27/wind-turbine.csv')
wind_turbine %>%
mutate(
manufacturer2 = case_when(
manufacturer == "Vestas" ~ "Vestas",
manufacturer == "GE" ~ "GE",
manufacturer == "Siemens" ~ "Siemens",
manufacturer == "Enercon" ~ "Enercon",
manufacturer == "Senvion" ~ "Senvion",
TRUE ~ "Other"),
manufacturer2 = factor (manufacturer2, levels = c("Vestas",
"GE",
"Siemens",
"Enercon",
"Senvion",
"Other")),
project_name2 = case_when(
project_name == "Blackspring Ridge Wind" ~ "Blackspring Ridge Wind",
project_name == "Gros-Morne" ~ "Gros-Morne",
project_name == "K2 Wind Power Facility" ~ "K2 Wind Power Facility",
project_name == "Lac Alfred" ~ "Lac Alfred",
project_name == "McBride Lake" ~ "McBride Lake",
project_name == "Melancthon" ~ "Melancthon",
project_name == "Prince Wind Energy Project" ~ "Prince Wind Energy Project",
project_name == "Rivière-du-Moulin" ~ "Rivière-du-Moulin",
project_name == "Seigneurie de Beaupré" ~ "Seigneurie de Beaupré",
project_name == "South Kent Wind Farm" ~ "South Kent Wind Farm",
project_name == "Underwood Wind Farm" ~ "Underwood Wind Farm",
TRUE ~ "Other"),
project_name2 = factor(project_name2, levels = c("Blackspring Ridge Wind",
"Gros-Morne",
"K2 Wind Power Facility",
"Lac Alfred",
"McBride Lake",
"Melancthon",
"Prince Wind Energy Project",
"Rivière-du-Moulin",
"Seigneurie de Beaupré",
"South Kent Wind Farm",
"Underwood Wind Farm",
"Other"))
) ->
wind_turbine
cnd <- map_data("world", region = "Canada")
cnd %>%
ggplot(aes(x = long, y = lat))+
geom_map(map = cnd, fill = "lightgray", aes(map_id = region))+
geom_point(data = wind_turbine,
aes(x = longitude, y = latitude))+
coord_quickmap()+
theme_void()
cnd %>%
ggplot(aes(x = long, y = lat))+
geom_map(map = cnd, fill = "lightgray", aes(map_id = region))+
geom_point(data = wind_turbine,
aes(x = longitude, y = latitude, color = manufacturer2))+
coord_quickmap()+
theme_void()+
labs(color = "")+
theme(legend.position = "bottom")
cnd %>%
ggplot(aes(x = long, y = lat))+
geom_map(map = cnd, fill = "gray95", aes(map_id = region))+
geom_point(data = wind_turbine,
aes(x = longitude, y = latitude, color = total_project_capacity_mw))+
coord_quickmap()+
theme_void()+
facet_wrap(~project_name2)+
theme(legend.position = "bottom")+
scale_color_gradient(low = "lightblue", high = "tomato")+
labs(title = "Canadian Wind Turbines by top projects",
caption = "data from tidytuesday",
color = "electrical capacity in megawatts")
cnd %>%
ggplot(aes(x = long, y = lat))+
geom_map(map = cnd, fill = "gray95", aes(map_id = region))+
geom_point(data = wind_turbine,
aes(x = longitude, y = latitude, color = turbine_rated_capacity_k_w))+
coord_quickmap()+
theme_void()+
facet_wrap(~project_name2)+
theme(legend.position = "bottom")+
scale_color_gradient(low = "lightblue", high = "tomato")+
labs(title = "Canadian Wind Turbines by top projects",
caption = "data from tidytuesday",
color = "turbine capacity in kilowatts")
cnd %>%
filter(!str_detect(subregion, "\\d"),
!is.na(subregion)) %>%
ggplot(aes(x = long, y = lat))+
geom_map(map = cnd, fill = "gray95", aes(map_id = region))+
geom_point(data = wind_turbine,
aes(x = longitude, y = latitude, color = turbine_rated_capacity_k_w))+
coord_quickmap()+
theme_void()+
facet_wrap(~subregion)
theme(legend.position = "bottom")+
scale_color_gradient(low = "lightblue", high = "tomato")+
labs(title = "Canadian Wind Turbines by top projects",
caption = "data from tidytuesday",
color = "turbine capacity in kilowatts")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment