Converts the shapes table to a LINESTRING sf object.
Arguments
- gtfs
A GTFS object, as created by
read_gtfs().- shape_id
A character vector including the
shape_ids to be converted. IfNULL(the default), all shapes are converted.- crs
The CRS of the resulting object, either as an EPSG code or as an
crsobject. Defaults to 4326 (WGS 84).
Examples
# read gtfs
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
shapes_sf <- get_shapes_geometry(gtfs)
head(shapes_sf)
#> Simple feature collection with 6 features and 1 field
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -46.69114 ymin: -23.64631 xmax: -46.47121 ymax: -23.48005
#> Geodetic CRS: WGS 84
#> shape_id geometry
#> 1 17838 LINESTRING (-46.64105 -23.6...
#> 2 17839 LINESTRING (-46.60321 -23.4...
#> 3 17840 LINESTRING (-46.58193 -23.5...
#> 4 17841 LINESTRING (-46.69114 -23.5...
#> 5 17842 LINESTRING (-46.66696 -23.5...
#> 6 17843 LINESTRING (-46.47127 -23.5...
shapes_sf <- get_shapes_geometry(gtfs, shape_id = "17846")
shapes_sf
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -46.87255 ymin: -23.53517 xmax: -46.63535 ymax: -23.19474
#> Geodetic CRS: WGS 84
#> shape_id geometry
#> 1 17846 LINESTRING (-46.63535 -23.5...
