General Bikeshare Feed Specification (GBFS)
R Package that connects to the GBFS API
North American Bike Share Association
library(devtools)
install_github("ds-civic-data/gbfs")
library(gbfs)
library(tidyverse)
library(ggmap)
library(kableExtra)
withr::with_dir(tempdir(), get_gbfs(city = "https://gbfs.fordgobike.com/gbfs/gbfs.json", feeds = "all", directory = "pdx_gbfs"))
withr::with_dir(tempdir(), list.files("pdx_gbfs"))
[1] "station_information.rds" "station_status.rds" "system_alerts.rds" "system_information.rds" "system_regions.rds"
station_information <- withr::with_dir(tempdir(), readRDS("pdx_gbfs/station_information.rds"))
head(station_information)
station_id name short_name lat lon region_id rental_methods capacity rental_url eightd_has_key_dispenser
1 74 Laguna St at Hayes St SF-J21 37.77643 -122.4262 3 CREDITCARD, KEY 27 http://app.fordgobike.com/Z6gL/SiFlGfIOTF?station_id=74 FALSE
2 3 Powell St BART Station (Market St at 4th St) SF-G27 37.78638 -122.4049 3 CREDITCARD, KEY 35 http://app.fordgobike.com/Z6gL/SiFlGfIOTF?station_id=3 FALSE
3 4 Cyril Magnin St at Ellis St SF-G26 37.78588 -122.4089 3 CREDITCARD, KEY 35 http://app.fordgobike.com/Z6gL/SiFlGfIOTF?station_id=4 FALSE
4 5 Powell St BART Station (Market St at 5th St) SF-H26 37.78390 -122.4084 3 CREDITCARD, KEY 35 http://app.fordgobike.com/Z6gL/SiFlGfIOTF?station_id=5 FALSE
5 6 The Embarcadero at Sansome St SF-A27 37.80477 -122.4032 3 CREDITCARD, KEY 23 http://app.fordgobike.com/Z6gL/SiFlGfIOTF?station_id=6 FALSE
6 7 Frank H Ogawa Plaza OK-L5 37.80456 -122.2717 12 CREDITCARD, KEY 35 http://app.fordgobike.com/Z6gL/SiFlGfIOTF?station_id=7 FALSE
eightd_station_services has_kiosk
1 6d9eb7b8-a412-407a-b424-5fa8c4ae96ba, ATTENDED_SERVICE, LIMITED, UNLIMITED, Valet, , , TRUE
2 NULL TRUE
3 NULL TRUE
4 NULL TRUE
5 NULL TRUE
6 NULL TRUE
station_information %>% ggplot(aes(x=lon, y=lat, color=region_id)) + geom_point()
bayarea <- get_map(location = "hayward")
Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=hayward&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=hayward&sensor=false
ggmap(bayarea) +
geom_point(data = station_information, aes(x = lon, y = lat, color = region_id, alpha = 0.1), size = 2, shape = 19) # 21
system_regions <- withr::with_dir(tempdir(), readRDS("pdx_gbfs/system_regions.rds"))
system_regions %>%
head() %>%
kable(format = "rst")
========= =============
region_id name
========= =============
3 San Francisco
5 San Jose
12 Oakland
13 Emeryville
14 Berkeley
23 8D
========= =============
East Bay
Oakland
Near real time data
oakland.status %>% group_by(name) %>%
summarise(n=n(),mean=mean(num_bikes_available),min=min(num_bikes_available),max=max(num_bikes_available)) %>%
kable(format = "rst")
=========================================== === ========== === ===
name n mean min max
=========================================== === ========== === ===
10th Ave at E 15th St 7 3.5714286 3 5
10th St at Fallon St 7 12.0000000 11 13
13th St at Franklin St 7 12.7142857 12 13
14th St at Filbert St 7 11.7142857 10 14
14th St at Mandela Pkwy 7 3.1428571 2 4
19th Street BART Station 7 6.4285714 3 11
21st Ave at International Blvd 7 11.0000000 11 11
23rd Ave at Foothill Blvd 7 9.7142857 9 10
24th St at Market St 7 12.0000000 10 16
26th Ave at International Blvd 7 8.0000000 8 8
27th St at MLK Jr Way 7 9.4285714 9 10
2nd Ave at E 18th St 7 8.2857143 8 9
32nd St at Adeline St 7 3.0000000 3 3
34th St at Telegraph Ave 7 8.7142857 8 9
45th St at Manila 7 1.7142857 0 2
45th St at MLK Jr Way 7 2.0000000 2 2
49th St at Telegraph Ave 7 7.8571429 7 9
55th St at Telegraph Ave 7 7.7142857 6 9
Alcatraz Ave at Shattuck Ave 7 5.5714286 4 6
Bay Pl at Vernon St 7 12.8571429 5 17
Broadway at 30th St 7 4.0000000 3 5
Broadway at 40th St 7 12.5714286 11 15
Broadway at Coronado Ave 7 4.5714286 3 5
Bushrod Park 7 5.4285714 4 6
College Ave at Bryant Ave 7 0.0000000 0 0
College Ave at Harwood Ave 7 2.7142857 2 3
College Ave at Taft Ave 7 3.0000000 3 3
DeFremery Park 7 5.0000000 5 5
Dover St at 57th St 7 0.5714286 0 2
E 12th St at 4th Ave 7 7.0000000 7 7
E 12th St at 6th Ave 7 5.0000000 5 5
El Embarcadero at Grand Ave 7 9.1428571 6 16
Foothill Blvd at 42nd Ave 7 5.0000000 5 5
Foothill Blvd at Fruitvale Ave 7 10.7142857 10 11
Foothill Blvd at Harrington Ave 7 8.0000000 8 8
Frank H Ogawa Plaza 7 11.8571429 7 17
Franklin St at 9th St 7 7.4285714 7 8
Fruitvale Ave at International Blvd 7 14.0000000 14 14
Fruitvale BART Station 7 2.0000000 1 3
Genoa St at 55th St 7 1.5714286 1 2
Grand Ave at Perkins St 7 11.2857143 8 16
Grand Ave at Santa Clara Ave 7 6.7142857 6 7
Grand Ave at Webster St 7 3.1428571 2 4
Isabella St at San Pablo Ave 7 0.7142857 0 1
Jack London Square 7 18.1428571 14 26
Jackson St at 11th St 7 7.0000000 7 7
Lake Merritt BART Station 7 7.2857143 6 9
Lakeshore Ave at Trestle Glen Rd 7 8.0000000 7 9
Lakeside Dr at 14th St 7 15.2857143 15 16
MacArthur BART Station 7 5.8571429 5 8
MacArthur Blvd at Telegraph Ave 7 5.8571429 5 7
Market St at 40th St 7 8.7142857 7 9
Market St at 45th St 7 6.0000000 6 6
Market St at 8th St 7 11.1428571 11 12
Market St at Brockhurst St 7 0.0000000 0 0
Marston Campbell Park 7 9.7142857 9 10
Miles Ave at Cavour St (Temporary Location) 7 8.0000000 8 8
MLK Jr Way at 14th St 7 5.0000000 5 5
MLK Jr Way at 36th St (Temporary Location) 7 10.0000000 10 10
Mosswood Park 7 15.1428571 14 16
Rockridge BART Station 7 2.1428571 0 3
San Antonio Park 7 5.7142857 5 6
San Pablo Ave at 27th St 7 13.2857143 13 14
San Pablo Ave at MLK Jr Way 7 5.2857143 5 6
Shattuck Ave at 51st St 7 2.7142857 2 3
Shattuck Ave at 55th St 7 2.7142857 2 3
Shattuck Ave at Telegraph Ave 7 3.8571429 2 5
Snow Park 7 7.5714286 7 9
Telegraph Ave at 19th St 7 8.2857143 7 11
Telegraph Ave at 23rd St 7 7.2857143 7 8
Telegraph Ave at 27th St 7 9.7142857 7 11
Telegraph Ave at 58th St 7 7.0000000 7 7
Telegraph Ave at Alcatraz Ave 7 2.7142857 2 3
Union St at 10th St 7 7.7142857 7 8
Washington St at 8th St 7 12.2857143 12 13
Webster St at 19th St 7 14.5714286 14 15
Webster St at 2nd St 7 7.1428571 5 8
West Oakland BART Station 7 6.8571429 3 9
West St at 40th St 7 8.8571429 6 10
=========================================== === ========== === ===
system_alerts <- withr::with_dir(tempdir(), readRDS("pdx_gbfs/system_alerts.rds"))
system_alerts %>% unlist() %>%
head()
NULL
system_information <- withr::with_dir(tempdir(), readRDS("pdx_gbfs/system_information.rds"))
system_information %>%
head()
system_id language name short_name operator url
1 BA en Ford GoBike Ford GoBike Motivate International, Inc. http://www.fordgobike.com
purchase_url start_date phone_number email license_url timezone
1 2017-05-14 855-480-BIKE US/Pacific
system_regions <- withr::with_dir(tempdir(), readRDS("pdx_gbfs/system_regions.rds"))
system_regions %>%
head() %>%
kable(format = "rst")
========= =============
region_id name
========= =============
3 San Francisco
5 San Jose
12 Oakland
13 Emeryville
14 Berkeley
23 8D
========= =============