General Bikeshare Feed Specification (GBFS)

R Package that connects to the GBFS API

R gbfs

North American Bike Share Association

NBSA system.csv

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           
=========  =============
LS0tDQp0aXRsZTogIkZvcmQgR28gQmlrZSBBUEkiDQp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