Skip to content

Instantly share code, notes, and snippets.

@idshklein
Created October 4, 2023 12:19
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 idshklein/61dc335c969354b5149420ccc9cff407 to your computer and use it in GitHub Desktop.
Save idshklein/61dc335c969354b5149420ccc9cff407 to your computer and use it in GitHub Desktop.
get night lines to plot
pacman::p_load(tidyverse,sf,jsonlite,geojsonsf,glue,patchwork,ggspatial)
layla <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=9cf3237f-80cd-4646-836f-f1370088430a&filters={%22RouteParticular%22:%22%D7%9C%D7%99%D7%9C%D7%94%22}&limit=1000")
kav_layla <- layla$result$records %>% map_df(~.x)
with_geoms <- kav_layla %>%
mutate(g = map2(RouteID,RouteDirection,possibly(function(x,y){glue("https://www.markav.net/shapes?q={x}-{y}-%23") %>% geojson_sf()},NA),.progress = TRUE))
aq <- with_geoms %>%
group_by(RouteID) %>%
filter(row_number()==1) %>%
filter(!is.na(g)) %>%
select(g) %>%
unnest() %>%
st_sf() %>%
group_split(route_id) %>%
map(~ggplot(.x) +
annotation_map_tile(zoomin = -1)+
geom_sf() +
facet_wrap(~route_id))
aq[1:10] %>% accumulate(`+`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment