diff --git a/.Rbuildignore b/.Rbuildignore index b4685b75..6fc47527 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,8 +10,6 @@ (^|/)venv(/.*)?$ LICENSE.md CITATION.cff -^doc$ -^Meta$ ^scratch$ cache (^|/)[^/]*cache[^/]*(/.*)?$ diff --git a/CITATION.cff b/CITATION.cff index 5e393d2d..e7ec2a37 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -12,6 +12,10 @@ authors: - family-names: Félix given-names: Rosa orcid: 'https://orcid.org/0000-0002-5642-6006' +dentifiers: + - type: doi + value: 10.32614/CRAN.package.GTFShift + description: CRAN repository-code: 'https://github.com/U-Shift/GTFShift' url: 'https://u-shift.github.io/GTFShift/' abstract: 'GTFShift encompasses a complete bundle of methods to harmonize GTFS and OSM data, enabling the integration and exploration of different layers of transit data, starting with the planned operations (GTFS), but also the infrastructure topology (OSM) and real-time information (GTFS-RT).' diff --git a/DESCRIPTION b/DESCRIPTION index 39ee81f4..a8d6d50b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Type: Package Package: GTFShift Title: Explore and Analyse General Transit Feed Specification (GTFS) Files with a Focus on Urban Mobility -Version: 0.12.0 +Version: 1.0.0 Authors@R: c( person(c("Gonçalo", "F."), "Matos", , "goncaloafmatos@tecnico.pt", role = c("aut", "cre"), comment = c(ORCID = "0009-0001-3489-1732")), @@ -57,7 +57,6 @@ Suggests: VignetteBuilder: knitr Config/Needs/website: rmarkdown -Config/roxygen2/version: 8.0.0 +Config/roxygen2/version: 8.1.0 Encoding: UTF-8 Language: en-US -RoxygenNote: 7.3.3 diff --git a/NAMESPACE b/NAMESPACE index 27e4fef4..1cb466b9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -35,28 +35,42 @@ import(rlang) import(sf) import(tidytransit) importFrom(callr,r_bg) -importFrom(gtfstools,convert_sf_to_shapes) -importFrom(gtfstools,merge_gtfs) -importFrom(httr,GET) -importFrom(httr,POST) -importFrom(httr,add_headers) -importFrom(httr,content) -importFrom(httr,http_error) -importFrom(httr,http_status) -importFrom(httr,status_code) -importFrom(jsonlite,fromJSON) -importFrom(jsonlite,write_json) +importFrom(gtfstools, + convert_sf_to_shapes, + merge_gtfs +) +importFrom(httr, + GET, + POST, + add_headers, + content, + http_error, + http_status, + status_code +) +importFrom(jsonlite, + fromJSON, + write_json +) importFrom(purrr,map_dfr) importFrom(rlang,.data) -importFrom(stats,setNames) -importFrom(stats,weighted.mean) -importFrom(stringr,regex) -importFrom(stringr,str_detect) +importFrom(stats, + setNames, + weighted.mean +) +importFrom(stringr, + regex, + str_detect +) importFrom(tidyr,unnest) importFrom(tidyselect,any_of) -importFrom(utils,head) -importFrom(utils,tail) -importFrom(utils,write.table) -importFrom(xml2,read_xml) -importFrom(xml2,xml_attr) -importFrom(xml2,xml_find_all) +importFrom(utils, + head, + tail, + write.table +) +importFrom(xml2, + read_xml, + xml_attr, + xml_find_all +) diff --git a/R/create_shapes_from_sf.R b/R/create_shapes_from_sf.R index cf36de61..7b98871c 100644 --- a/R/create_shapes_from_sf.R +++ b/R/create_shapes_from_sf.R @@ -28,6 +28,7 @@ #' \code{shape_dist_traveled} if \code{shape_dist_traveled = TRUE}. #' #' @examples +#' \donttest{ #' # Load sample GTFS #' gtfs <- GTFShift::load_feed(system.file("extdata/samples", #' "gtfs_tcb_sample.zip", package = "GTFShift") @@ -49,6 +50,7 @@ #' ) #' #' head(shapes_txt) +#' } #' #' @import sf #' @importFrom gtfstools convert_sf_to_shapes diff --git a/R/multiline_to_sorted_linestring.R b/R/multiline_to_sorted_linestring.R index bc8999c2..009f4a73 100644 --- a/R/multiline_to_sorted_linestring.R +++ b/R/multiline_to_sorted_linestring.R @@ -59,6 +59,7 @@ #' @returns sfc. LINESTRING geometry object. #' #' @examples +#' \donttest{ #' # Get OSM route geometries (MULTILINESTRING) #' osm_routes <- sf::st_read( #' system.file("extdata/samples", "osm_routes_tcb.gpkg", package = "GTFShift"), @@ -73,6 +74,7 @@ #' ) #' #' head(osm_routes) +#' } #' #' @import dplyr #' @import sf diff --git a/R/network_overline.R b/R/network_overline.R index 0e072eb9..56c336db 100644 --- a/R/network_overline.R +++ b/R/network_overline.R @@ -20,6 +20,7 @@ #' @returns sf. Spatial network object extended with aggregated values. #' #' @examples +#' \donttest{ #' # Subset GTFS for one route only, for demo purposes #' gtfs <- GTFShift::load_feed(system.file("extdata/samples", #' "gtfs_tcb_sample.zip", package = "GTFShift") @@ -55,6 +56,7 @@ #' }) #' #' head(overline |> st_drop_geometry()) +#' } #' #' @seealso \code{stplanr::rnet_join()} #' diff --git a/R/query_osm_centerlines.R b/R/query_osm_centerlines.R index 8559aa19..06e226e9 100644 --- a/R/query_osm_centerlines.R +++ b/R/query_osm_centerlines.R @@ -18,12 +18,13 @@ #' This method was adapted from \href{https://uscuni.org/neatnet/intro.html}{uscuni.org/neatnet} #' by \href{https://github.com/miguelrelvaspires}{Miguel Relvas Pires} in the scope of #' his \href{https://scholar.tecnico.ulisboa.pt/records/DhKWeFU5YLpMDcOhQbKR4f7ul05HCQnZr7ND}{master's thesis}. -#' The full code (Python) of his work is openly available at +#' The full code (Python) of his work is openly available at #' \href{https://github.com/U-Shift/lp_streets}{GitHub}. #' #' @returns sf data.frame. OSM centerlines. #' -#' @examplesIf reticulate::py_module_available("neatnet") +#' @examples +#' \dontrun{ #' # Get sample OSM extract #' osm_file <- system.file("extdata/samples", "relation_6384187.pbf", package = "GTFShift") #' @@ -35,6 +36,7 @@ #' head(network) #' #' table(network$X_status) +#' } #' #' @author \href{https://github.com/miguelrelvaspires}{Miguel Relvas Pires} #' diff --git a/R/rt_average_speed.R b/R/rt_average_speed.R index 8411b223..ebe28a31 100644 --- a/R/rt_average_speed.R +++ b/R/rt_average_speed.R @@ -74,6 +74,7 @@ #' } #' #' @examples +#' \donttest{ #' # Get GTFS-RT data collection #' rt_collect_file <- system.file( #' "extdata/samples", "gtfs_rt_sample_tcb_4_4-CS-TERM.csv", package = "GTFShift" @@ -112,6 +113,8 @@ #' ) #' #' nrow(speed) +#' } +#' #' #' @seealso \code{GTFShift::project_points_along_geometry()} #' @seealso \code{GTFShift::multiline_to_sorted_linestring()} diff --git a/R/rt_collect_protobuf.R b/R/rt_collect_protobuf.R index 85349172..386ef0ad 100644 --- a/R/rt_collect_protobuf.R +++ b/R/rt_collect_protobuf.R @@ -16,6 +16,7 @@ #' @returns String. The location of the file where data was collected. #' #' @examples +#' \dontrun{ #' # Create file #' destination_file <- withr::local_tempfile(fileext = ".csv") #' @@ -35,6 +36,7 @@ #' collection |> #' dplyr::select("vehicle.trip.trip_id", "vehicle.position.latitude", "vehicle.position.longitude") #' ) +#' } #' #' @importFrom jsonlite write_json #' @importFrom stats setNames diff --git a/README.md b/README.md index 74f564c4..d914d498 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,24 @@ # GTFShift logo -[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21292010.svg)](https://doi.org/10.5281/zenodo.21292010) [![](https://github.com/U-Shift/GTFShift/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/U-Shift/GTFShift/actions/workflows/R-CMD-check.yaml) [![codecov](https://codecov.io/gh/U-Shift/GTFShift/graph/badge.svg?token=RWVWEGGOF8)](https://codecov.io/gh/U-Shift/GTFShift) +[![CRAN status](https://www.r-pkg.org/badges/version/GTFShift)](https://cran.r-project.org/package=GTFShift/) +[![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) +[![CRAN downloads total](https://cranlogs.r-pkg.org/badges/grand-total/GTFShift?color=lightgrey)](https://cran.r-project.org/package=GTFShift) +[![](https://github.com/U-Shift/GTFShift/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/U-Shift/GTFShift/actions/workflows/R-CMD-check.yaml) +[![codecov](https://codecov.io/gh/U-Shift/GTFShift/graph/badge.svg?token=RWVWEGGOF8)](https://codecov.io/gh/U-Shift/GTFShift) **GTFShift** encompasses a complete bundle of methods to harmonize GTFS and OSM data, enabling the integration and exploration of different layers of transit data, starting with the planned operations (GTFS), but also the infrastructure topology (OSM) and real-time information (GTFS-RT). ## Installation -You can install the development version of **GTFShift** from -[GitHub](https://github.com/) with: +You can install the stable version of **GTFShift** from CRAN: + +``` r +install.packages('GTFShift') +``` + +For the development version, fetch from GitHub: ``` r # install.packages("remotes") @@ -33,7 +42,7 @@ For more details on the package and how to get started, please visit the [Get st The lack of standardization on GTFS shape geometries hampers aggregated analysis of different feeds and the association of planned service information with other urban dimensions such as the infrastructure topology. -To solve this problem, **GTFShift** provides a bundle of methods to harmonize GTFS shapes with OSM road network geometries. Refer to [Get OSM data for bus routes](articles/osm.html#get-osm-data-for-bus-routes) and [Generate GTFS with OSM geometries](articles/gtfs_from_osm.html) for more details. +To solve this problem, **GTFShift** provides a bundle of methods to harmonize GTFS shapes with OSM road network geometries. Refer to [Get OSM data for bus routes](https://u-shift.github.io/GTFShift/articles/osm.html#get-osm-data-for-bus-routes) and [Generate GTFS with OSM geometries](https://u-shift.github.io/GTFShift/articles/gtfs_from_osm.html) for more details. ![](man/figures/geometry_harmonization_barreiro.png) @@ -67,9 +76,9 @@ a minimum frequency of 10 buses/hour, average speed below 9.7 km/h and more than **GTFShift** provides an interactive dashboard that allows users to explore and visualize results for real case studies, aiming to illustrate its potential and capabilities to a non-technical audience, while disseminating the outputs of these real world scenarios. -Visit it at [ushift.pt/apps/gtfshift](https://ushift.pt/apps/gtfshift). +Visit it at [ushift.pt/apps/gtfshift](https://ushift.tecnico.ulisboa.pt/apps/gtfshift/). -[![](man/figures/web.png)](https://ushift.pt/apps/gtfshift) +[![](man/figures/web.png)](https://ushift.tecnico.ulisboa.pt/apps/gtfshift/) ## Related packages diff --git a/_pkgdown.yml b/_pkgdown.yml index 6e7e1340..2a98f6df 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -13,7 +13,7 @@ navbar: components: dashboard: text: "Bus lane prioritisation dashboard" - href: "https://ushift.pt/apps/gtfshift" + href: "https://ushift.tecnico.ulisboa.pt/apps/gtfshift/" target: "_blank" diff --git a/man/create_shapes_from_sf.Rd b/man/create_shapes_from_sf.Rd index beb34c9e..c3376be6 100644 --- a/man/create_shapes_from_sf.Rd +++ b/man/create_shapes_from_sf.Rd @@ -46,6 +46,7 @@ distance along each shape for all generated points and appends this as \code{metric_crs}, using \code{GTFShift::project_points_along_geometry()}. } \examples{ +\donttest{ # Load sample GTFS gtfs <- GTFShift::load_feed(system.file("extdata/samples", "gtfs_tcb_sample.zip", package = "GTFShift") @@ -67,6 +68,7 @@ shapes_txt <- GTFShift::create_shapes_from_sf( ) head(shapes_txt) +} } \seealso{ diff --git a/man/multiline_to_sorted_linestring.Rd b/man/multiline_to_sorted_linestring.Rd index 50008694..f52d0b48 100644 --- a/man/multiline_to_sorted_linestring.Rd +++ b/man/multiline_to_sorted_linestring.Rd @@ -76,6 +76,7 @@ The ordered segments are concatenated into a single \code{LINESTRING} and transformed back to the original CRS of \code{multilinestring}. } \examples{ +\donttest{ # Get OSM route geometries (MULTILINESTRING) osm_routes <- sf::st_read( system.file("extdata/samples", "osm_routes_tcb.gpkg", package = "GTFShift"), @@ -90,5 +91,6 @@ osm_routes <- osm_routes |> dplyr::mutate( ) head(osm_routes) +} } diff --git a/man/network_overline.Rd b/man/network_overline.Rd index b350a865..ad2fb26e 100644 --- a/man/network_overline.Rd +++ b/man/network_overline.Rd @@ -44,6 +44,7 @@ creates an aggregated network based on the lines overlap. Instead, \code{GTFShif segment, the overlapping lines and aggregates their \code{attr} values, using \code{fun}. } \examples{ +\donttest{ # Subset GTFS for one route only, for demo purposes gtfs <- GTFShift::load_feed(system.file("extdata/samples", "gtfs_tcb_sample.zip", package = "GTFShift") @@ -79,6 +80,7 @@ suppressWarnings({ }) head(overline |> st_drop_geometry()) +} } \seealso{ diff --git a/man/osm_centerlines.Rd b/man/osm_centerlines.Rd index cc734377..9810a1e3 100644 --- a/man/osm_centerlines.Rd +++ b/man/osm_centerlines.Rd @@ -41,11 +41,11 @@ the network simplification process. This method was adapted from \href{https://uscuni.org/neatnet/intro.html}{uscuni.org/neatnet} by \href{https://github.com/miguelrelvaspires}{Miguel Relvas Pires} in the scope of his \href{https://scholar.tecnico.ulisboa.pt/records/DhKWeFU5YLpMDcOhQbKR4f7ul05HCQnZr7ND}{master's thesis}. -The full code (Python) of his work is openly available at +The full code (Python) of his work is openly available at \href{https://github.com/U-Shift/lp_streets}{GitHub}. } \examples{ -\dontshow{if (reticulate::py_module_available("neatnet")) withAutoprint(\{ # examplesIf} +\dontrun{ # Get sample OSM extract osm_file <- system.file("extdata/samples", "relation_6384187.pbf", package = "GTFShift") @@ -57,7 +57,8 @@ network <- GTFShift::osm_centerlines( head(network) table(network$X_status) -\dontshow{\}) # examplesIf} +} + } \author{ \href{https://github.com/miguelrelvaspires}{Miguel Relvas Pires} diff --git a/man/rt_average_speed.Rd b/man/rt_average_speed.Rd index 3a2d2f9c..541799df 100644 --- a/man/rt_average_speed.Rd +++ b/man/rt_average_speed.Rd @@ -93,6 +93,7 @@ Method \code{GTFShift::multiline_to_sorted_linestring()} can be used to convert geometries to LINESTRING if needed. } \examples{ +\donttest{ # Get GTFS-RT data collection rt_collect_file <- system.file( "extdata/samples", "gtfs_rt_sample_tcb_4_4-CS-TERM.csv", package = "GTFShift" @@ -131,6 +132,8 @@ head(speed |> ) nrow(speed) +} + } \seealso{ diff --git a/man/rt_collect_protobuf.Rd b/man/rt_collect_protobuf.Rd index 2c3a307e..f0e41543 100644 --- a/man/rt_collect_protobuf.Rd +++ b/man/rt_collect_protobuf.Rd @@ -40,6 +40,7 @@ Downloads GTFS-RT data from the specified URL at regular intervals and saves the This function will run indefinitely until manually stopped (CTRL + C). } \examples{ +\dontrun{ # Create file destination_file <- withr::local_tempfile(fileext = ".csv") @@ -59,5 +60,5 @@ head( collection |> dplyr::select("vehicle.trip.trip_id", "vehicle.position.latitude", "vehicle.position.longitude") ) - +} } diff --git a/vignettes/articles/GTFShift.Rmd b/vignettes/GTFShift.Rmd similarity index 75% rename from vignettes/articles/GTFShift.Rmd rename to vignettes/GTFShift.Rmd index 287f01f4..ecad05da 100644 --- a/vignettes/articles/GTFShift.Rmd +++ b/vignettes/GTFShift.Rmd @@ -1,5 +1,10 @@ --- title: "Get Started" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Get Started} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} @@ -12,8 +17,15 @@ knitr::opts_chunk$set( # Installation -You can install the development version of `GTFShift` from GitHub with: -```{r} +You can install the stable version of **GTFShift** from CRAN: + +```{r, eval=FALSE} +install.packages('GTFShift') +``` + +For the development version, fetch from GitHub: + +```{r, eval=FALSE} # install.packages("remotes") remotes::install_github("U-Shift/GTFShift") ``` @@ -29,15 +41,15 @@ library(GTFShift) **GTFShift** provides methods for the entire workflow of bus lane implementation prioritisation, but also other useful functions for GTFS and OSM data gathering and manipulation. For detailed examples on their functionality, refer to -the [articles](./index.html). +the [articles](https://u-shift.github.io/GTFShift/articles/index.html). -### [Prioritise](./prioritise.html) +### [Prioritise](https://u-shift.github.io/GTFShift/articles/prioritise.html) The main purpose of **GTFShift** is to support the decision-making process for bus lane implementation prioritisation. This article presents a step-by-step guide on how to use the package to achieve this goal, from data gathering to analysis and visualization. -### [Getting transit data](./download.html) +### [Getting transit data](https://u-shift.github.io/GTFShift/articles/download.html) Starting with a valid GTFS feed is the key for a successful analysis. **GTFShift** includes a method to load feeds that simultaneously scans @@ -47,7 +59,7 @@ If the feed location is unknown, it also provides a database listing GTFS for Portugal and a method to query worldwide open catalogues by city or country names or even a bounding box. -### [Filter](./filter.html) +### [Filter](https://u-shift.github.io/GTFShift/articles/filter.html) GTFS feeds do not have a defined scope regarding its coverage of the transportation system. Some can be bounded to one agency, whereas others @@ -57,7 +69,7 @@ From the simpler to the most complex feeds, some analysis require to narrow the perspective. **GTFShift** provides some to help in this process. -### [Aggregate](./unify.html) +### [Aggregate](https://u-shift.github.io/GTFShift/articles/unify.html) Public transit analysis takes advantage of the standardized GTFS format. However, its provision by operator makes it difficult for network @@ -71,7 +83,7 @@ file given several instances. > Aggregated GTFS for Fertagus and Transportes Coletivos do Barreiro > operators -### [Analyse](./analyse.html) +### [Analyse](https://u-shift.github.io/GTFShift/articles/analyse.html) Analyzing public transit feeds is important to understand its territorial coverage and dynamics, both on its spatial and temporal @@ -85,7 +97,7 @@ stop, route or road segment. > Aggregated route frequency for Carris Lisboa operator, at 8:00 -### [OSM Data](./osm.html) +### [OSM Data](https://u-shift.github.io/GTFShift/articles/osm.html) OpenStreetMaps (OSM) is an important data source for transit analysis, due to its rich, open, and detailed geographic data. @@ -98,22 +110,22 @@ network and export the OSM transit routes. > OSM exported bus lanes for Lisbon -### [Real Time transit data](./rt.html) +### [Real Time transit data](https://u-shift.github.io/GTFShift/articles/rt.html) Real time operational data provides valuable insights about how planned operation performs in practice and how it interacts with the urban traffic conditions. **GTFShift** provides several methods to enable this data collection and analysis. -### [Contribute to OSM](./osm_update.html) +### [Contribute to OSM](https://u-shift.github.io/GTFShift/articles/osm_update.html) OpenStreetMap (OSM) is a collaborative project that relies on community contributions. **GTFShift** includes methods to facilitate the process of contributing to OSM, specifically for updating bus lane information based on the analysis results. -### [Generate GTFS with OSM geometries](./gtfs_from_osm.html) +### [Generate GTFS with OSM geometries](https://u-shift.github.io/GTFShift/articles/gtfs_from_osm.html) The lack of standardization on GTFS shape geometries hampers aggregated analysis of different feeds and the association of planned service information with other urban dimensions such as the infrastructure topology. -**GTFShift** provides methods to generate a GTFS file with OSM geometries. \ No newline at end of file +**GTFShift** provides methods to generate a GTFS file with OSM geometries. diff --git a/vignettes/articles/figures/analyse_aggregated_frequencies.png b/vignettes/figures/analyse_aggregated_frequencies.png similarity index 100% rename from vignettes/articles/figures/analyse_aggregated_frequencies.png rename to vignettes/figures/analyse_aggregated_frequencies.png diff --git a/vignettes/articles/figures/osm_buslanes.png b/vignettes/figures/osm_buslanes.png similarity index 100% rename from vignettes/articles/figures/osm_buslanes.png rename to vignettes/figures/osm_buslanes.png diff --git a/vignettes/articles/figures/unify.png b/vignettes/figures/unify.png similarity index 100% rename from vignettes/articles/figures/unify.png rename to vignettes/figures/unify.png