Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (33 sloc)
1.25 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #load packages | |
| library(tidyverse) | |
| library(sf) | |
| library(layer) | |
| library(ragg) | |
| #notin function | |
| `%notin%` <- Negate(`%in%`) | |
| #load shape file | |
| shape <- read_sf("Alternative_Fueling_Stations.shp") | |
| #filter to public stations | |
| public_shapes <- shape %>% filter(ACCESS_COD=="public") | |
| #filter to continental United States | |
| cont_shapes <- public_shapes %>% filter(STATE %notin% c("AK", "HI", "PR")) | |
| #create maps | |
| electric <- st_as_sf(cont_shapes %>% filter(FUEL_TYPE_ == "ELEC")) | |
| propane <- st_as_sf(cont_shapes %>% filter(FUEL_TYPE_ == "LPG")) | |
| biodiesel <- st_as_sf(cont_shapes %>% filter(FUEL_TYPE_ == "BD")) | |
| ethanol <- st_as_sf(cont_shapes %>% filter(FUEL_TYPE_ == "E85")) | |
| #create tilted maps | |
| tilt_electric <- tilt_map(electric) | |
| tilt_ethanol <- tilt_map(ethanol, y_shift=50) | |
| tilt_propane <- tilt_map(propane, y_shift=100) | |
| tilt_biodiesel <- tilt_map(biodiesel, y_shift=150) | |
| #put maps in list | |
| maps_list <- list(tilt_electric, tilt_ethanol, tilt_propane, tilt_biodiesel) | |
| #plot tilted maps | |
| plot <- plot_tiltedmaps(maps_list, | |
| layer = c("value", "value", "value", "value"), | |
| palette = c("magma", "magma", "magma", "magma")) | |
| #save plot | |
| ggsave("layered map - plain.png", | |
| plot, | |
| device = agg_png(width = 8, height = 10, units = "in", res = 300)) |