GTFS Shapes To Features (Conversion)

Summary

Converts a GTFS shapes.txt file from a GTFS public transit dataset to a polyline feature class showing the physical paths taken by vehicles in the public transit system.

If possible, attributes from the routes.txt file are included for each shape in the output, and output lines are symbolized according to the color specified in the route_color field.

The shapes.txt file contains sequences of latitude and longitude points. This tool generates shape polylines by connecting these sequences of points with straight lines.

Note:

The GTFS Shapes To Features tool and the Generate Shapes Features From GTFS tool are used for different purposes. Use GTFS Shapes To Features if your GTFS dataset includes an existing shapes.txt file and you want to convert these shapes to a feature class to display in the map. Use Generate Shapes Features From GTFS if your GTFS dataset does not include an existing shapes.txt file and you want to estimate the shapes based on the other information contained in the GTFS dataset and create a shapes.txt file.

Usage

  • Route attributes will be populated only if valid trips.txt and routes.txt files are located in the same folder as the input shapes.txt file.

  • A file geodatabase feature class is recommended for tool output instead of a shapefile. Because shapefile field names can have a maximum of only 10 characters, longer GTFS field names will be shortened if the output table is a shapefile.

  • Route attributes are populated for each shape using the following process: For each shape_id in the shapes.txt file, the tool checks the trips.txt file to find the trips with this shape_id and finds the route_id associated with these trips. The tool then retrieves the attributes for that route_id from the routes.txt file and puts these attributes in the output feature class of shapes. In the unusual case that more than one route_id is associated with a given shape_id, the shape will be duplicated in the output feature class so that there is one feature for each unique shape_id and route_id pair.

Parameters

LabelExplanationData Type
Input GTFS Shapes File

A valid shapes.txt file from a GTFS dataset.

File
Output Feature Class

The output feature class.

Feature Class

arcpy.conversion.GTFSShapesToFeatures(in_gtfs_shapes_file, out_feature_class)
NameExplanationData Type
in_gtfs_shapes_file

A valid shapes.txt file from a GTFS dataset.

File
out_feature_class

The output feature class.

Feature Class

Code sample

GTFSShapesToFeatures example (Python window)

The following code sample demonstrates how to use the GTFSShapesToFeatures function in the Python window.

arcpy.transit.GTFSShapesToFeatures(r"D:/GTFS/shapes.txt", r"D:/Data/output.gdb/shapes")

Environments