Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elipousson/3caa6f57fb8bcb539884976e273b7f38 to your computer and use it in GitHub Desktop.
Save elipousson/3caa6f57fb8bcb539884976e273b7f38 to your computer and use it in GitHub Desktop.
library(dplyr)
library(ggplot2)
school <-
get_location(
type = bcpss::bcps_programs_SY2021,
id_col = "program_number",
id = 7
)
school_area <-
st_bbox_ext(
x = school,
dist = 0.25,
unit = "mile",
asp = 1
)
intersections_pt <-
get_location_data(
location = school_area,
data = mapbaltimore::named_intersections
)
intersections_curb <-
get_location_data(
location = school_area,
data = "edge_of_pavement",
package = "mapbaltimore"
) %>%
sf::st_filter(intersections_pt) %>%
dplyr::left_join(sf::st_drop_geometry(intersections_pt), by = "id") %>%
dplyr::select(-type) %>%
relocate_sf_col()
area_streets <-
get_location_data(
data = mapbaltimore::streets,
location = school_area
)
numbered_streets <-
area_streets %>%
group_by(fullname) %>%
summarise() %>%
number_features(sort = "ymax", desc = TRUE) %>%
sf::st_drop_geometry() %>%
select(number, fullname)
intersection_index <-
intersections_curb %>%
st_dist(to = school, drop = TRUE) %>%
arrange(across(starts_with("dist"))) %>%
number_features(sort = NULL)
intersection_index_map <-
ggplot() +
layer_mapbox(
data = school_area,
asp = "11:8.5",
scaling_factor = "2x"
) +
layer_location_data(
data = intersection_index,
mapping = aes(label = number),
geom = "label")
ggsave_ext(
plot = intersection_index_map,
name = "Cecil ES SRTS intersection reference map",
prefix = "date",
device = cairo_pdf,
filetype = "pdf",
width = 11,
height = 8.5,
dpi = 72
)
intersection_index %>%
write_sf_gsheet(name = "Cecil ES street intersection index")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment