Skip To Content

GTFS Shapes To Features

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.

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 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.

Syntax

GTFSShapesToFeatures_conversion (in_gtfs_shapes_file, out_feature_class)
ParameterExplanationData 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 Python window script demonstrates how to use the GTFSShapesToFeatures function in immediate mode.

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

Environments

Licensing information

  • ArcGIS Desktop Basic: Yes
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes

Related topics