Summary
Creates a point feature class containing live traffic-incident data from a web service. Traffic incidents include events such as accidents and road construction.
Usage
You need to have an account with one of the data providers listed in the Provider parameter before this tool can download traffic data.
If you run this tool multiple times using the same output workspace and feature class name, all prior features are deleted before creating new ones.
Syntax
UpdateTrafficIncidents_na (provider, user_name, password, regions, incidents_feature_class_location, incidents_feature_class_name, {time_zone_boundaries}, {time_zone_id_field})
Parameter | Explanation | Data Type |
provider | Choose the name of your traffic-incident data provider and the region.
| String |
user_name | The user name authorized by the data provider to download incidents. The tool fails to execute if the user name cannot be authenticated by the data provider. If the Provider parameter is TomTom North America or TomTom Europe, use APIKEY as the parameter value. | String |
password | The password provided by the data provider to download traffic-incident data. The tool fails to execute if the password cannot be authenticated by the data provider. | Encrypted String |
regions [regions,...] | Enter the regions for which you want to download traffic-incident data. To download all available regions, type "#". | String |
incidents_feature_class_location | The geodatabase in which the output feature class will be created. This workspace must already exist. | Workspace; Feature Dataset |
incidents_feature_class_name | The name of the feature class to be created. If the tool has been run before and the feature class already exists, the tool will delete existing features and create new ones based on the most recent incident data. | String |
time_zone_boundaries (Optional) | The polygon feature class whose features delineate time zones. By providing this feature class, incidents occurring within time zone boundaries can be reported in local time, not only Coordinated Universal Time. If you don't provide a time zone boundaries feature class, incident start and end times can be reported in Coordinated Universal Time (UTC) only; all local time fields are assigned null values. Occasionally, certain incidents from traffic feeds such as weather events have null geometries. In this situation, the local time fields are assigned null values even if the time zone boundaries feature class is provided. Setting the Time Zone ID Field property is required if you provide a time-zone-boundaries feature class. | Feature Layer |
time_zone_id_field (Optional) | The text field, from the time-zone-boundaries feature class, that contains Windows time zone identifiers. The values in this field correspond to time zone keys in the Windows registry. You can follow similar steps to those outlined in the topic Adding time zones to a network dataset to find proper time zone names for the polygons in your input feature class. | Field |
Code sample
UpdateTrafficIncidents example 1 (Python window)
The following Python window script demonstrates how to use the UpdateTrafficIncidents tool.
import arcpy
arcpy.na.UpdateTrafficIncidents("NAVTEQ North America", "myUserName",
"myPassword",
["New England", "New York/Northern NJ/Connecticut"],
"C:/Data/Traffic.gdb","Traffic_Incidents",
"C:/data/TimeZones.gdb/NATimeZones", "MSTIMEZONE")
UpdateTrafficIncidents example 2 (workflow)
The following stand alone Python script describes how the UpdateTrafficIncidents tool can be used to download traffic incidents as a feature class in an enterprise geodatabase. The script can be run as a Windows Scheduler Task or a cron job on Linux so that the traffic incidents are updated at regular intervals. The feature class can be used to publish a feature service.
# Name: UpdateTrafficIncidents_Workflow.py
# Description: Downloads traffic incidents as a feature class in an ArcSDE
# geodatabase. The script can be run as a Windows Scheduler Task or
# a cron job on Linux so that the traffic incidents are updated at
# regular intervals. The feature class can be used to publish a
# feature service.
#Import system modules
import arcpy
from arcpy import env
#Set local variables
trafficIncidentsStorage = "C:/data/TrafficIncidentsStorage.sde"
incidentsFeatureClass = "NAVTEQ_NorthAmerica_Incidents"
provider = "NAVTEQ North America"
username = "Replace with your username"
password = "Replace with your password"
#download data for all regions
regions = "#"
timeZoneBoundaries = "C:/data/TimeZones.gdb/NATimeZones"
timeZonesID = "MSTIMEZONE"
try:
#Update Traffic Data. Use default values for remaining parameters
arcpy.na.UpdateTrafficIncidents(provider,username,password, regions,
trafficIncidentsStorage, incidentsFeatureClass,
timeZoneBoundaries, timeZonesID)
print "Script completed successfully."
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print "An error occurred on line %i" % tb.tb_lineno
print str(e)
Environments
Licensing information
- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes