This file contains hidden or 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
{ | |
"version": 8, | |
"name": "osm-style", | |
"metadata": { | |
"maputnik:renderer": "mbgljs", | |
"license": "https://creativecommons.org/publicdomain/zero/1.0/" | |
}, | |
"glyphs": "https://tiles.versatiles.org/assets/fonts/{fontstack}/{range}.pbf", | |
"sprite": "https://tiles.versatiles.org/assets/sprites/sprites", | |
"sources": { |
This file contains hidden or 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
pacman::p_load(WikidataQueryServiceR,tidyverse,sf,qgisprocess,ggrepel) | |
qgis_configure() | |
data <- query_wikidata(' | |
SELECT ?place ?placeLabel ?time ?location ?instanceLabel | |
WHERE | |
{ | |
wd:Q2910987 wdt:P625 ?loc . | |
SERVICE wikibase:around { | |
?place wdt:P625 ?location . | |
bd:serviceParam wikibase:center ?loc . |
This file contains hidden or 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
pacman::p_load(tidyverse,jsonlite,stringdist) | |
res <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=70ba1705-3b25-416f-939c-985999f87f35&limit=10000") | |
df <- res$result$records %>% map_df(~.x) %>% | |
filter(`סוג ישוב`!="מוקד תעסוקה") %>% | |
mutate(cntr = row_number()) | |
dist_geo <- df %>% | |
select(`אורדינטה מזרחית`,`אורדינטה צפונית`) %>% | |
dist() %>% as.matrix() | |
res1 <- map(df$`שם ישוב`,~stringdist(.x,df$`שם ישוב`, method='jw')) | |
matrix_from_list <- do.call(cbind, res1) |
This file contains hidden or 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
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) %>% |
This file contains hidden or 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
pacman::p_load(tidyverse,jsonlite,lubridate) | |
js <- | |
read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=e265857e-9f53-419f-ad0b-860d2bf6fbb8&filters={%22StationId%22:[%2217112%22,%2217111%22,%2217113%22,%2217110%22]}&limit=100000") | |
js$result$records %>% | |
map_df(~.x) %>% | |
gather(day,count,starts_with("day_")) %>% | |
mutate(day = str_remove(day,"day_")) %>% | |
mutate(date = ymd(paste(year_key,month_key,day,sep = "/")),.keep = "unused") %>% | |
mutate(count = coalesce(as.numeric(count),0)) %>% | |
filter(!is.na(date)) %>% |
This file contains hidden or 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
pacman::p_load(tidyverse,sf,osmdata,tidygraph,ggraph,igraph,RCurl,mapview,stringdist) | |
admin_level_8 <- osmdata_sf ('[out:xml][timeout:25];(rel["admin_level"="8"](area:3601473946););out body;>;out skel qt;') | |
admin_level_8$osm_polygons | |
city_names <- admin_level_8$osm_multipolygons %>% | |
st_drop_geometry() %>% | |
as_tibble() %>% | |
distinct(name,osm_id) %>% | |
filter(!sapply(admin_level_8$osm_multipolygons$name, function(texte) { | |
grepl("[\\s\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF]", texte) | |
}), str_length(osm_id) < 8) |
This file contains hidden or 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
pacman::p_load(jsonlite,tidyverse,sf,lubridate,ggspatial) | |
df <- read_json("https://open-bus-stride-api.hasadna.org.il/siri_rides/list?gtfs_route__route_mkt=59015>fs_route__route_direction=2&limit=200000") | |
# df <- read_json("https://open-bus-stride-api.hasadna.org.il/siri_rides/list?gtfs_route__route_mkt=13490>fs_route__route_direction=3&limit=200000") | |
df1 <- df %>% map_df(~.x) | |
s_vec <- seq(1,nrow(df1),500) | |
e_vec <- c(seq(500,nrow(df1),500),nrow(df1)) | |
starts <- map2_dfr(s_vec,e_vec,~read_json(paste0("https://open-bus-stride-api.hasadna.org.il/siri_vehicle_locations/list?get_count=false&limit=100000&siri_vehicle_location_ids=",df1$first_vehicle_location_id[.x:.y] %>% paste0(collapse = ","))))%>% map_df(~.x) | |
ends <- map2_dfr(s_vec,e_vec,~read_json(paste0("https://open-bus-stride-api.hasadna.org.il/siri_vehicle_locations/list?get_count=false&limit=100000&siri_vehicle_location_ids=",df1$last_vehicle_location_id[.x:.y] %>% paste0(collapse = ","))))%>% map_df(~.x) | |
start15 <- c(35.213151,31.746651) %>% st_point() |
This file contains hidden or 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
pacman::p_load(gtfstools,lubridate,tidyverse) | |
gtfs <- read_gtfs("C:/Users/idshk/Downloads/israel-public-transportation (5).zip") | |
stop_city <- read_delim("C:/Users/idshk/Downloads/e873e6a2-66c1-494f-a677-f5e77348edb0.csv",delim = "|") | |
dfq <- gtfs$stop_times %>% | |
left_join(gtfs$stops, by = "stop_id") %>% | |
mutate(stop_code = as.numeric(stop_code)) %>% | |
left_join(stop_city, by = c("stop_code"="StationId")) %>% | |
distinct(trip_id,stop_code,CityName) %>% | |
left_join(gtfs$trips, by = "trip_id") %>% | |
left_join(gtfs$routes, by = "route_id") %>% |
This file contains hidden or 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
pacman::p_load(tidyverse,sf,sfnetworks,nngeo,tidygraph) | |
options(scipen = 10000) | |
outer = matrix(c(0,0,1000,0,1000,1000,0,1000,0,0),ncol=2, byrow=TRUE) | |
make_grid <- function(street_length){st_polygon(list(outer)) %>% | |
st_make_grid(street_length) %>% | |
st_segments() } | |
x <- 200 | |
map_df(c(2,4,5,8,10,20),~make_grid(1000/.x) %>% | |
st_segmentize(20) %>% | |
st_segments() %>% |
This file contains hidden or 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
pacman::p_load(tidyverse,jsonlite,lubridate,rayshader) | |
df_2019 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=5ed3ac9d-0709-46fb-aa42-1156682f3b85&limit=389&filters={%22OfficeLineId%22:%2224100%22}") | |
df_2020 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=6042d958-d86f-40bc-803b-2c5620d90394&limit=392&filters={%22OfficeLineId%22:%2224100%22}") | |
df_2021 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=09de377b-6462-48d5-8470-177c17016f6e&limit=405&filters={%22OfficeLineId%22:%2224100%22}") | |
df_2022 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=bfd22231-7a8b-4fc0-91bd-342397860ab5&limit=440&filters={%22OfficeLineId%22:%2224100%22}") | |
dfis <- function(df){df$result$records %>% map_df(~.x)} | |
dfis(df_2019) %>% | |
bind_rows(dfis(df_2020)) %>% | |
bind_rows(dfis(df_2021)) %>% | |
mutate_all(as.character) %>% |
NewerOlder