Skip to content

Instantly share code, notes, and snippets.

pacman::p_load(tidyverse,sf,sfdep,sfnetworks,waywiser,tidygraph)
nc = st_read(system.file("shape/nc.shp", package="sf"))
# waywiser- only polygons
waywiser::ww_build_neighbors(nc)
# sfnetworks - neighboring points connected by edges
st_intersects(nc,nc) %>%
imap_dfr(~data.frame(from=.y,to=.x)) %>%
filter(from!=to) %>%
as_tbl_graph() %>%
left_join(st_centroid(nc) %>% mutate(rn=row_number() %>% as.character()),by=c("name"="rn")) %>%
pacman::p_load(tidyverse,jsonlite,lubridate)
rishui <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&limit=300000")
rishui1 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&offset=300000&limit=300000")
rishui2 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&offset=600000&limit=300000")
rishui3 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&offset=900000&limit=300000")
rishhi_all <- list(rishui,rishui1,rishui2,rishui3)
tbl <- rishhi_all %>%
map_df(~.x$result$records %>% map_df(~.x))
tbl %>% glimpse()
library(tidyverse)
library(jsonlite)
library(lubridate)
library(hms)
res3 <- map(0:25,function(x){
print(x)
res2 <- read_json(paste0("https://open-bus-stride-api.hasadna.org.il/siri_rides/list?siri_route__line_refs=7005&order_by=siri_route_id%20asc%2Cvehicle_ref%20desc&offset=",x*100))
df2 <- map_df(1:length(res2),~res2[[.x]])
df2
})
library(tidyverse)
library(jsonlite)
library(lubridate)
library(sf)
res3 <- map(0:12,function(x){
print(x)
res2 <- read_json(paste0("https://open-bus-stride-api.hasadna.org.il/siri_vehicle_locations/list?lon__greater_or_equal=35.1998&lon__lower_or_equal=35.201&lat__greater_or_equal=31.754&lat__lower_or_equal=31.7558&offset=",1+x*100,"&recorded_at_time_from=2022-03-09T00:00:00.000Z&recorded_at_time_to=2022-03-20T00:00:00.000Z"))
df2 <- map_df(1:length(res2),~res2[[.x]])
df2
})
library(tidyverse)
library(sf)
library(sfnetworks)
library(tidygraph)
library(dbscan)
stations <- st_read("METRO_STAT.shp")
lines <- st_read("METRO_LINE.shp")
plot(stations$geometry)
clus <- st_coordinates(stations) %>%
dbscan(eps = 300,minPts = 1) %>%
library(tidyverse)
library(jsonlite)
library(lubridate)
library(hms)
library(sf)
library(ggspatial)
library(gtfstools)
library(sfnetworks)
library(ggimage)
library(imputeTS)
library(tidyverse)
library(readxl)
library(sf)
library(igraph)
library(tidygraph)
library(mapview)
nat <- read_csv("C:/idos_shit/celular1819_v1/v_1/AvgDayHourlyTrips201819_1270_weekday_v1.csv")
# nat <- read_csv("C:/idos_shit/celular1819_v1/v_1/AvgDayHourlyTrips201819_1270_friday_v1.csv")
# nat <- read_csv("C:/idos_shit/celular1819_v1/v_1/AvgDayHourlyTrips201819_1270_saturday_v1.csv")
shp1 <- st_read("C:/idos_shit/celular1819_v1/v_1/Shape files/1270_02.09.2021.shp",options = "ENCODING=WINDOWS-1255")
library(rwhatsapp)
library(tidyverse)
library(sf)
library(ggspatial)
library(lubridate)
library(gridExtra)
library(patchwork)
library(hms)
library(gganimate)
Sys.setlocale(locale = "hebrew")
library(tidyverse)
library(sf)
library(sfnetworks)
library(igraph)
library(tidygraph)
library(ggspatial)
eds <- st_read("D:/Downloads/israel-ISR_gpkg/tel_aviv-4309.gpkg",layer = "edges") %>% st_transform(2039) %>% select(geom)
net <- as_sfnetwork(eds) %>%
convert(to_spatial_smooth)
library(tidyverse)
library(sf)
library(lubridate)
library(gganimate)
library(ggspatial)
day <- st_read("D:/Downloads/history-2021-11-08.kml")
OlsonNames()
PERIODS <- 10
all <- day %>%
st_transform(2039) %>%