Last active
July 17, 2016 15:36
-
-
Save patperu/5826510e88126d7eb1039fbc3827021f to your computer and use it in GitHub Desktop.
Find missing routes in the GTFS dataset (V08) from Palermo
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
library("rvest") | |
library("gtfsr") | |
library("dplyr") | |
library('tidyr') | |
amat_url <- "http://www.amat.pa.it/Le_Linee/linee_orario.php" | |
# read the AMAT leweb form | |
web_routes <- function(url) { | |
ses <- html_session(url) | |
ses_form <- html_form(ses)[[1]] | |
web_routes <- names(ses_form$fields$name$options) | |
out <- data.frame(route_id = web_routes, stringsAsFactors = FALSE) | |
out$service_id <- "web" | |
out | |
} | |
# read gtfs | |
# httr::set_config(httr::config(ssl_verifypeer = 0L)) | |
# url <- "https://github.com/openamat/Official-Data/raw/master/amat_feed_gtfs_v8.zip" | |
# amat <- url %>% import_gtfs | |
# BOM fixed | |
amat <- import_gtfs("amat_v08_fix.zip", local = TRUE) | |
trips <- unique(amat[['trips_df']][1:2]) | |
web <- web_routes(amat_url) | |
fin <- rbind(trips, web) | |
fin <- tbl_df(fin) %>% | |
mutate(n = 1) %>% | |
spread(service_id, n) %>% | |
arrange(route_id) | |
write.csv(fin, file = "matched_routes.csv", | |
fileEncoding = "UTF-8", row.names = FALSE) |
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
route_id | FE | FR | web | |
---|---|---|---|---|
100 | NA | NA | 1 | |
101 | 1 | 1 | 1 | |
102 | 1 | 1 | 1 | |
103 | 1 | 1 | 1 | |
104 | 1 | 1 | 1 | |
106 | NA | NA | 1 | |
107 | 1 | 1 | 1 | |
108 | NA | NA | 1 | |
109 | 1 | 1 | 1 | |
110 | 1 | 1 | 1 | |
118 | 1 | 1 | 1 | |
124 | 1 | 1 | 1 | |
134 | 1 | 1 | 1 | |
209 | 1 | 1 | 1 | |
210 | 1 | 1 | 1 | |
212 | 1 | 1 | 1 | |
224 | 1 | 1 | 1 | |
224P | NA | 1 | NA | |
226 | NA | NA | 1 | |
230 | 1 | 1 | 1 | |
231 | NA | NA | 1 | |
234 | 1 | 1 | 1 | |
237 | 1 | 1 | 1 | |
241 | 1 | 1 | 1 | |
243 | 1 | 1 | 1 | |
246 | 1 | 1 | 1 | |
304 | 1 | 1 | 1 | |
307 | NA | NA | 1 | |
309 | 1 | 1 | 1 | |
327 | 1 | 1 | 1 | |
364 | 1 | 1 | 1 | |
380 | NA | NA | 1 | |
389 | 1 | 1 | 1 | |
422 | 1 | 1 | 1 | |
442 | NA | NA | 1 | |
462 | 1 | 1 | 1 | |
513 | 1 | 1 | 1 | |
529 | 1 | 1 | 1 | |
534 | NA | NA | 1 | |
544 | 1 | 1 | 1 | |
603 | 1 | 1 | 1 | |
606 | NA | NA | 1 | |
614 | 1 | 1 | 1 | |
616 | 1 | 1 | 1 | |
619 | NA | NA | 1 | |
625 | 1 | 1 | 1 | |
628 | 1 | 1 | 1 | |
628P | 1 | 1 | NA | |
645 | 1 | 1 | 1 | |
675 | 1 | 1 | 1 | |
704 | 1 | 1 | 1 | |
721 | NA | 1 | 1 | |
731 | 1 | 1 | 1 | |
806 | NA | NA | 1 | |
812 | NA | NA | 1 | |
84 | 1 | 1 | 1 | |
85 | 1 | 1 | 1 | |
86 | NA | NA | 1 | |
87 | 1 | 1 | 1 | |
88 | 1 | 1 | 1 | |
ARANC | 1 | 1 | NA | |
H2 | NA | NA | 1 | |
NAVETTA ARANCIONE CENTRO STORICO | NA | NA | 1 | |
NAVETTA CIVICO | NA | NA | 1 | |
NAVETTA EXPRESS | NA | NA | 1 | |
NOTTURNO 11 | NA | NA | 1 | |
NOTTURNO 12 | NA | NA | 1 | |
NOTTURNO 21 | NA | NA | 1 | |
NOTTURNO 22 | NA | NA | 1 | |
TRAM1 | NA | NA | 1 | |
TRAM2 | NA | NA | 1 | |
TRAM3 | NA | NA | 1 | |
TRAM4 | NA | NA | 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment