{"id":15617905,"url":"https://github.com/simonpcouch/gbfs","last_synced_at":"2025-04-09T17:24:29.993Z","repository":{"id":56721589,"uuid":"127068214","full_name":"simonpcouch/gbfs","owner":"simonpcouch","description":"An R package to interface with bikeshare data!","archived":false,"fork":false,"pushed_at":"2025-01-13T16:23:51.000Z","size":7293,"stargazers_count":37,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T02:40:18.407Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gbfs.netlify.app","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonpcouch.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-28T01:50:03.000Z","updated_at":"2025-03-22T11:06:57.000Z","dependencies_parsed_at":"2022-08-16T00:20:26.154Z","dependency_job_id":null,"html_url":"https://github.com/simonpcouch/gbfs","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonpcouch%2Fgbfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonpcouch%2Fgbfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonpcouch%2Fgbfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonpcouch%2Fgbfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonpcouch","download_url":"https://codeload.github.com/simonpcouch/gbfs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248075609,"owners_count":21043623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T08:00:51.542Z","updated_at":"2025-04-09T17:24:29.970Z","avatar_url":"https://github.com/simonpcouch.png","language":"R","readme":"---\noutput: github_document\n---\n\n```{r, echo = FALSE, message = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"figures/\"\n)\ndevtools::load_all()\n```\n\n# General Bikeshare Feed Specification \u003cimg src=\"https://raw.githubusercontent.com/simonpcouch/gbfs/main/figures/hex.png\" alt=\"A hexagonal logo with a black border and white background showing a green bicycle icon.\" align=\"right\" width=280 /\u003e\n\n[![CRAN status](https://www.r-pkg.org/badges/version/gbfs)](https://cran.r-project.org/package=gbfs)\n[![R build status](https://github.com/simonpcouch/gbfs/workflows/R-CMD-check/badge.svg)](https://github.com/simonpcouch/gbfs/actions)\n[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/gbfs)](https://cran.r-project.org/package=gbfs)\n\nThe `gbfs` package supplies a set of functions to interface with General\nBikeshare Feed Specification .json feeds in R, allowing users to save\nand accumulate tidy .rds datasets for specified cities/bikeshare programs.\nThe North American Bikeshare Association's [gbfs](https://github.com/MobilityData/gbfs)\nis a standardized data release format for live information on the status\nof bikeshare programs, as well as metadata, including counts of bikes at \nstations, ridership costs, and geographic locations of stations and\nparked bikes. \n\n__Features__\n\n* Get bikeshare data by specifying city name or supplying url of feed\n* All feeds for a city can be saved with a single function\n* New information from dynamic feeds can be appended to existing datasets\n\n## Installation\n\nWe're on CRAN! Install the latest release with:\n\n```{r cran-installation, eval = FALSE}\ninstall.packages(\"gbfs\")\nlibrary(gbfs)\n```\n\nYou can install the developmental version of `gbfs` from GitHub with:\n\n```{r gh-installation, eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"simonpcouch/gbfs\")\n```\n\n## Background\n\nThe `gbfs` is a standardized data feed describing the current status of a\nbikeshare program.   \n\nAlthough all of the data is live, only a few of the datasets change often:\n\n* `station_status`: Supplies the number of available bikes and \ndocks at each station as well as station availability\n* `free_bike_status`: Gives the coordinates and metadata on available\nbikes that are parked, but not at a station.\n\nIn this package, these two datasets are considered \"dynamic\", and can be\nspecified as desired datasets by setting `feeds = \"dynamic\"` in the \nmain wrapper function in the package, `get_gbfs`.\n\nMuch of the data supplied in this specification can be considered static. If you\nwant to grab all of these for a given city, set `feeds = \"static\"` when calling\n`get_gbfs`. Static feeds include:\n\n* `system_information`: Basic metadata about the bikeshare program\n* `station_information`: Information on the capacity and coordinates of stations\n* Several optional feeds: `system_hours`, `system_calendar`, `system_regions`,\n`system_pricing_plans`, and `system_alerts`\n\nEach of the above feeds can be queried with the `get_suffix` function, where\n`suffix` is replaced with the name of the relevant feed.\n\nFor more details on the official `gbfs` spec, see \n[this document](https://github.com/MobilityData/gbfs/blob/master/gbfs.md).\n\n## Example\n\nIn this example, we'll grab data from Portland, Oregon's Biketown bikeshare\nprogram and visualize some of the different datasets.\n\n```{r, warning = FALSE, message = FALSE}\n# load necessary packages\nlibrary(tidyverse)\n```\n\n\nFirst, we'll grab some information on the stations.\n\n```{r}\n# grab portland station information and return it as a dataframe\npdx_station_info \u003c- \n  get_station_information(\"https://gbfs.lyft.com/gbfs/1.1/pdx/gbfs.json\")\n\n# check it out!\nglimpse(pdx_station_info)\n```\n\n...as well as the number of bikes at each station.\n\n```{r}\n# grab current capacity at each station and return it as a dataframe\npdx_station_status \u003c- \n  get_station_status(\"https://gbfs.lyft.com/gbfs/1.1/pdx/gbfs.json\")\n\n# check it out!\nglimpse(pdx_station_status)\n```\n\nJust like that, we have two tidy datasets containing information about \nPortland's bikeshare program.\n\nJoining these datasets, we can get the capacity at each station, along with each\nstation's metadata.\n\n```{r}\n# full join these two datasets on station_id and select a few columns\npdx_stations \u003c- full_join(pdx_station_info, \n                          pdx_station_status, \n                          by = \"station_id\") %\u003e%\n  # just select columns we're interested in visualizing\n  select(id = station_id, \n         lon, \n         lat, \n         num_bikes_available, \n         num_docks_available) %\u003e%\n  mutate(type = \"docked\")\n```\n\nFinally, before we plot, lets grab the locations of the bikes parked in\nPortland that are not docked at a station,\n\n```{r}\n# grab data on free bike status and save it as a dataframe\npdx_free_bikes \u003c- \n  get_free_bike_status(\"https://gbfs.lyft.com/gbfs/1.1/pdx/gbfs.json\", \n                       output = \"return\") %\u003e%\n  # just select columns we're interested in visualizing\n  select(id = bike_id, lon, lat) %\u003e%\n  # make columns analogous to station_status for row binding\n  mutate(num_bikes_available = 1,\n         num_docks_available = NA,\n         type = \"free\")\n```\n\n...and bind these dataframes together!\n\n```{r}\n# row bind stationed and free bike info\npdx_full \u003c- bind_rows(pdx_stations, pdx_free_bikes)\n```\n\nNow, plotting,\n\n```{r plot}\n# filter out stations with 0 available bikes\npdx_plot \u003c- pdx_full %\u003e%\n  filter(num_bikes_available \u003e 0) %\u003e%\n  # plot the geospatial distribution of bike counts\n  ggplot() + \n  aes(x = lon, \n      y = lat, \n      size = num_bikes_available, \n      col = type) +\n  geom_point() +\n  # make aesthetics slightly more cozy\n  theme_minimal() +\n  scale_color_brewer(type = \"qual\")\n```\n\n```{r print-plot, eval = FALSE}\npdx_plot\n```\n\n\u003ca href='https://github.com/simonpcouch/gbfs'\u003e\u003cimg src='https://raw.githubusercontent.com/simonpcouch/gbfs/main/figures/plot-1.png' height=\"500\" /\u003e\u003c/a\u003e\n\nFolks who have spent a significant amount of time in Portland might be able to\npick out the Willamette River running Northwest/Southeast through the city.\nWith a few lines of `gbfs`, `dplyr`, and `ggplot2`, we can put together a\nmeaningful visualization to help us better understand how bikeshare bikes\nare distributed throughout Portland.\n\nSome other features worth playing around with in `gbfs` that weren't touched\non in this example:\n\n* The main wrapper function in the package, `get_gbfs`, will grab every\ndataset for a given city. (We call the functions to grab individual datasets\nabove for clarity.)\n* In the above lines, we output the datasets as returned dataframes. If you'd\nrather save the output to your local files, check out the `directory` and\n`return` arguments.\n* When the `output` argument is left as default in `get_free_bike_status` and\n`get_station_status` (the functions for the `dynamic` dataframes,)\nand a dataframe already exists at the given path, `gbfs` will row bind the\ndataframes, allowing for the capability to accumulate large datasets over time.\n* If you're not sure if your city supplies `gbfs` feeds, you might find the\n`get_gbfs_cities` and `get_which_gbfs_feeds` functions useful.\n\n## Contributing\n\nPlease note that the `gbfs` R package is released with a [Contributor Code of Conduct](CONTRIBUTING.md). By contributing to this project, you agree to abide by its terms.\n","funding_links":[],"categories":["Producing Data","Recently Updated"],"sub_categories":["Other multimodal data formats","[Oct 02, 2024](/content/2024/10/02/README.md)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonpcouch%2Fgbfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonpcouch%2Fgbfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonpcouch%2Fgbfs/lists"}