Learn R Programming

GTFSwizard (version 1.1.0)

get_stops_sf: Convert GTFS Stops Table to Simple Features (sf) Format

Description

`get_stops_sf` converts the stops table in a `wizardgtfs` object into a simple features (`sf`) object, making it suitable for spatial analysis. This function checks the format of the `stops` data and structures it as point geometries.

Usage

get_stops_sf(gtfs)

Value

An `sf` object with stops as point geometries or a `wizardgtfs` object.

Arguments

gtfs

A `wizardgtfs` object containing a `stops` table or the stops table itself as a data frame.

Details

- When the input `stops` table is not in `sf` format, this function converts it to `sf` by using the coordinates in the `stop_lon` and `stop_lat` columns.

- The resulting `sf` object is assigned a CRS of WGS 84 (EPSG:4326) for geographic compatibility.

- If the `stops` table is already in `sf` format, the function simply reassigns the CRS and returns it unchanged.

See Also

[GTFSwizard::get_shapes()], [GTFSwizard::get_shapes_sf()], [GTFSwizard::get_shapes_df()]

Examples

Run this code
# Convert stops data in a GTFS object to sf format
gtfs_sf <- get_stops_sf(for_rail_gtfs)

Run the code above in your browser using DataLab