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 already has a 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 have a 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.

Syntax

arcpy.conversion.GTFSShapesToFeatures(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

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics