Skip To Content

Connect Network Dataset Transit Sources To Streets

Summary

Connects transit stops to street features for use in a transit-enabled network dataset. This tool creates the StopsOnStreets and StopConnectors feature classes defined by the Network Analyst public transit data model and is intended to be run as part of a larger workflow for creating a transit-network dataset described in Create and use a network dataset with public transit data.

To realistically model travel by public transit in a network dataset, the network should allow pedestrians to walk to the transit stops, ride the transit, and then walk to their destinations. The network should include both public transit data and street data, and the transit stops and lines should be connected to the streets in a controlled manner. Pedestrians should only be able to enter or exit the transit lines at stops, and the stops must be connected to the streets. This tool ensures such a connection.

The tool will create a copy of the Stops feature class, which must be present in the target feature dataset, and snap the copied Stops features to the input streets features, subject to the specified search distance and expression. The tool will then create StopConnectors features by generating a straight line between each stop and its snapped copy, creating a connection between the stop's location and the location where it snapped to a street feature. Vertices will be added to the input streets features at the locations of the snapped stops to ensure good network dataset connectivity.

Transit stops can be connected to streets using a snapped version of the stops, a connector line, and a vertex on the street feature.
This illustration shows how transit stops can be connected to street features in the network dataset. Part 1 shows a transit stop (orange circle) along a transit line (blue line). Part 2 shows a vertex (green triangle) added to the closest point of the closest street feature (black line). Part 3 shows a copy of the stop snapped to the street feature (purple circle). Part 4 shows a connector line generated to connect the stop to the street. Pedestrian travel between the streets and the transit line is modeled using these connections and the connectivity policy on the network dataset.

Usage

  • The target feature dataset used in this tool must already exist and contain a point feature class called Stops with the schema described by the Network Analyst public transit data model. A valid Stops feature class can be created using the GTFS To Network Dataset Transit Sources tool.

  • The tool will snap public transit stops in your target feature dataset to the streets features. As with any edit operation, it is best to have all the features in the same spatial reference to avoid potential errors. It is recommended that you ensure that the target feature dataset and the input streets features have the same spatial reference.

  • The input streets features will be altered after running the tool. Vertices will be added at the locations where StopsOnStreets features intersect the streets. If you do not want your street data altered, make a copy of it before running this tool.

  • If the input Stops feature class contains parent stations (features with a GStopType value of 1), the parent stations will be connected to the streets, and child stops will be connected to the parent station. Stops with parent stations will not be directly connected to the streets.

    A stop with a parent station
    This is a stop with a parent station. The stop (orange circle) connects to the parent station (blue square) using a connector line (gray line) with ConnectorType 1. The parent station connects to the street using a connector line with ConnectorType 0.

  • If the input Stops feature class contains station entrances (features with a GStopType value of 2), the station entrances will be snapped to the streets, and parent stations will be connected to the station entrances. In this situation, the station entrances will be coincident with the streets, StopConnectors lines with a ConnectorType value of 2 will connect the parent station to its entrances, and StopConnectors lines with a ConnectorType value of 1 will connect stops to the parent station.

    A parent station with explicitly-defined station entrances
    This is a parent station with explicitly-defined station entrances. The stops (orange circles) connect to the parent station (blue square) using connector lines (gray lines) with ConnectorType 1. The parent station connects to the streets at the station entrance locations (green squares) using connector lines with ConnectorType 2.

  • The Stops feature class may be altered after running the tool. Stop features with a GStopType value of 2, representing station entrances, may be deleted. These stop features will instead be included in the output StopsOnStreets feature class to model correct connections from the streets, through the station entrances, and to the stops. Parent stations that are spatially coincident with stops may also be deleted.

  • When running this tool in stand-alone Python, if the input Stops feature class contains parent stations or station entrances, warning message 001059 may be written to the console. This warning message is expected and does not indicate a problem.

Syntax

ConnectNetworkDatasetTransitSourcesToStreets(target_feature_dataset, in_streets_features, search_distance, expression)
ParameterExplanationData Type
target_feature_dataset

The feature dataset where the transit-enabled network dataset will be created. This feature dataset must already exist and contain a point feature class called Stops with the schema described by the Network Analyst public transit data model. A valid Stops feature class can be created with the GTFS To Network Dataset Transit Sources tool.

Note:

The Stops feature class may be altered after running the tool. Stop features with a GStopType value of 2, representing station entrances, may be deleted. These stop features will instead be included in the output StopsOnStreets feature class to model correct connections from the streets, through the station entrances, and to the stops. Parent stations that are spatially coincident with stops may also be deleted.

Feature Dataset
in_streets_features

A polyline feature class of streets to which transit stops and lines will connect. This streets feature class should be the same feature class you intend to use in your transit-enabled network dataset for modeling pedestrians walking along streets. The feature class does not need to be in the target feature dataset to run this tool; however, the feature class must be in the target feature dataset at the time you create the network dataset.

Note:

The input streets features will be altered after running the tool. Vertices will be added at the locations where StopsOnStreets features intersect the streets. If you do not want your street data altered, make a copy of it before running this tool.

Feature Layer
search_distance

The search distance for snapping transit stops to the input street features. Stops that are outside the search distance will not be snapped and will not be connected to the streets. A small search distance will ensure that stops do not snap to streets that are far away, but it increases the likelihood of stops failing to snap when they should. A large search distance increases the number of stops likely to snap but may lead to errors that should instead be corrected by editing the street data. If no street features are found within the search distance of a particular stop, the output StopsOnStreets feature will not be snapped to a street and will be coincident with its corresponding feature in Stops, which could lead to poor connectivity in the network dataset at that location.

The default is 100 meters.

Linear Unit
expression

An SQL expression used to select a subset of input street feature records. Transit stops will be snapped only to street features matching this expression. For example, the expression could be used to prevent stops from snapping to streets where pedestrian travel is prohibited.

SQL Expression

Derived Output

NameExplanationData Type
updated_target_feature_dataset

The feature dataset to which the new feature classes have been added and existing ones may have been updated.

Feature Dataset
updated_in_streets_features

The input street feature class, which may have been modified by the tool.

Feature Class
updated_in_stops

The Stops feature class located in the target feature dataset, which may have been modified by the tool.

Feature Class
output_stops_on_streets

The StopsOnStreets feature class for the Network Analyst public transit data model, created by snapping a copy of the Stops features to the input street features.

Feature Class
output_stop_connectors

The StopConnectors feature class for the Network Analyst public transit data model, created by drawing a straight line between the original stop location and the location where it snapped to a streets feature.

Feature Class

Code sample

ConnectNetworkDatasetTransitSourcesToStreets example 1 (Python window)

The following script demonstrates how to use the ConnectNetworkDatasetTransitSourcesToStreets tool in the Python window.

fd_path = r"E:\TransitAnalysis\TransitNetwork.gdb\TransitNetwork"
streets = os.path.join(fd_path, "Streets")
where = "PedestriansAllowed = 1"
arcpy.conversion.ConnectNetworkDatasetTransitSourcesToStreets(fd_path, streets, "100 meters", where)
ConnectNetworkDatasetTransitSourcesToStreets example 2 (stand-alone script)

The following stand-alone Python script demonstrates how the GTFSToNetworkDatasetTransitSources and ConnectNetworkDatasetTransitSourcesToStreets tools can be used together to create a transit-enabled network dataset.

import os
import arcpy
arcpy.CheckOutExtension("network")

gtfs_folders = [
    r"E:\GTFS\Agency1",
    r"E:\GTFS\Agency2"
]
streets_orig = r"E:\Data\StreetData.gdb\Streets"

working_folder = r"E:\TransitAnalysis"
nd_template = os.path.join(working_folder, "TransitNetworkTemplate.xml")
gdb_name = "TransitNetwork.gdb"
out_gdb = os.path.join(working_folder, gdb_name)
fd_name = "TransitNetwork"
fd_path = os.path.join(out_gdb, fd_name)
streets = os.path.join(fd_path, "Streets")
nd_name = "TransitNetwork_ND"
nd_path = os.path.join(fd_path, nd_name)

# Create a file geodatabase and feature dataset to store the network dataset
arcpy.management.CreateFileGDB(working_folder, gdb_name)
arcpy.management.CreateFeatureDataset(out_gdb, fd_name, arcpy.SpatialReference(4326))

# Copy the streets data into the feature dataset so it can be used by the network dataset
# If the original streets are not in the same spatial reference as the feature dataset, you might
# need to use the Project tool instead of Copy.
arcpy.management.Copy(streets_orig, streets)

# Convert the GTFS dataset into public transit data model tables and feature classes
arcpy.conversion.GTFSToNetworkDatasetTransitSources(gtfs_folders, fd_path)

# Connect the transit stops to the streets and create the rest of the data model feature classes
# Use an expression to connect transit stops only to streets where pedestrians are allowed.
where = "PedestriansAllowed = 1"
arcpy.conversion.ConnectNetworkDatasetTransitSourcesToStreets(fd_path, streets, "100 meters", where)

# Create the network dataset from a template
arcpy.na.CreateNetworkDatasetFromTemplate(nd_template, fd_path)

# Build the network dataset
arcpy.na.BuildNetwork(nd_path)

Environments

This tool does not use any geoprocessing environments.

Licensing information

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

Related topics