get_shape_geometry: Get the geometry of a route shape

View source: R/gtfs_helpers.R

get_shape_geometryR Documentation

Get the geometry of a route shape

Description

This function returns an SF multilinestring of the route alignments from GTFS shapes. Similar to tidytransit::get_geometry(), but allows filtering by shape_id and projection to a new coordinate system. See Details for requirements on the input GTFS.

Usage

get_shape_geometry(gtfs, shape = NULL, project_crs = 4326)

Arguments

gtfs

A tidygtfs object.

shape

Optional. A vector of GTFS shape_ids to pull. Default is NULL, where all shape_ids in gtfs will be used.

project_crs

Optional. A numeric EPSG identifer indicating the coordinate system to use for spatial calculations. Consider setting to a Euclidian projection, such as the appropriate UTM zone. Default is 4326 (WGS 84 ellipsoid).

Details

A shapes file must be present in your GTFS object. This file must contain at least the following fields:

  • shape_id

  • shape_pt_lat

  • shape_pt_lon

  • shape_pt_sequence

Value

An SF multilinestring, with one multilinestring object per shape_id.

Examples

# Set my parameters
my_shape <- "804EB_RC_221121"
my_crs = 32611

# Get shape from WMATA GTFS
lineE_shape <- get_shape_geometry(gtfs = lacmta_gtfs,
                                  shape = my_shape,
                                  project_crs = my_crs)
print(lineE_shape)

transittraj documentation built on Nov. 2, 2026, 1:10 a.m.