
Convert GTFS shapes to simple feature object (deprecated)
Source:R/gtfs_as_sf.R
gtfs_shapes_as_sf.RdThis function is deprecated and will be removed in a future
version. Use gtfstools::get_shapes_geometry() and, for the length of
each shape, gtfstools::get_shape_length() instead.
Convert the shapes of a GTFS data loaded using
read_gtfs into a LINESTRING simple feature (sf) object, using
get_shapes_geometry, and add the length of each
shape in kilometres, using get_shape_length. The
input data is not modified.
Arguments
- gtfs
A GTFS data.
shape_idmust be character andshape_pt_sequenceinteger, as produced byread_gtfs.- crs
The coordinate reference system of the output: an EPSG code, a string accepted by
st_crs, or acrsobject. Shapes are read as WGS84 (EPSG:4326) and transformed tocrs. The default value is 4326 (no transformation). Other inputs (e.g.NA) raise an error, and an empty or unknown CRS raises an error of classgtfs2gps_crs_error.
Value
A simple feature (sf) object with columns shape_id,
geometry and length (km). The length is computed from the
WGS84 points of each shape, whatever crs is.
Examples
sp <- read_gtfs(system.file("extdata/saopaulo.zip", package = "gtfs2gps"))
#> Unzipped the following files to /tmp/RtmpL1LF2I/gtfsio:
#> * agency.txt
#> * calendar.txt
#> * frequencies.txt
#> * routes.txt
#> * shapes.txt
#> * stop_times.txt
#> * stops.txt
#> * trips.txt
#> Reading agency
#> Reading calendar
#> Reading frequencies
#> Reading routes
#> Reading shapes
#> Reading stop_times
#> Reading stops
#> Reading trips
sp_sf <- suppressWarnings(gtfs_shapes_as_sf(sp))