Convert the shapes of a GTFS data loaded using
read_gtfs into a LINESTRING simple feature (sf) object, using
convert_shapes_to_sf, and add the length of each
shape in kilometres. 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). It must be a valid CRS:NAor an unknown CRS raises an error of classgtfs2gps_crs_error.
Examples
poa <- read_gtfs(system.file("extdata/saopaulo.zip", package = "gtfs2gps"))
#> Unzipped the following files to /tmp/Rtmppl8S8P/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
poa_sf <- gtfs_shapes_as_sf(poa)
