Select to view content in your preferred language

MakeRouteEventLayer, any ideas on why variable for in event properties no work?

1000
1
08-24-2012 12:45 PM
MichaelMiller2
Frequent Contributor
I using the below code snippet to create a route event and will eventually set it up to accept input parameters for the route ID, begin MP and End MP. So I was thinking I test setting it up to "build" the in event properties input using string formatting. But the string I have assigned to the props variable does not seem to work.  Any ideas out there of what I am missing?

import arcpy
import os
arcpy.env.overwriteOutput = 1
arcpy.env.workspace = r"\\itdhq1apt50\GIS_Data\NeedsTracking\Scratch.gdb"
gdb_loc = arcpy.env.workspace
scratch = arcpy.env.scratchWorkspace
scratch_gdb = os.path.join(scratch, 'scratch.gdb')
print "starting this darn task"
arcpy.AddMessage("starting this darn task")

in_line = "Database Connections\CONNECTION SDE 4 MAPPING.sde\sdeProd.SDE.StateHighwayUpdateFile" #sde statehwy data used to create route file
rteID = "RD_NAME" # using this a route ID to create routes base on road number rather than segment no
#rteID = "UNIQUE_ID" # this will create routes based on segment no
outRoute = "StateHwyRouteFile"
outEvent = "lineTemp"
fc = "LineSelection"
#fc_prj = "PointsTestingWM"
fc_prj = os.path.join(scratch,'LineSelectionWM')
csWM = r"Coordinate Systems\Projected Coordinate Systems\World\WGS 1984 Web Mercator (Auxiliary Sphere).prj"
#table = arcpy.GetParameter(0)
table = gdb_loc + os.sep + "locateRoute"

inRoute = "routeID"
inBMP = "BMP"
inEMP = "EMP"
props = '"%s %s %s %s"' % (inRoute, 'LINE', inBMP, inEMP)
arcpy.MakeRouteEventLayer_lr(outRoute, rteID, table, props, outEvent, "#", "ERROR_FIELD")
#arcpy.MakeRouteEventLayer_lr(outRoute, rteID, table, "routeID LINE BMP EMP", outEvent, "#", "ERROR_FIELD")


Thanks
Tags (2)
0 Kudos
1 Reply
RichardDaniels
Honored Contributor

In python the seperator between your properties is the | symbol, not a space. Your properties would be "routeID|Line|inBMP|inEMP".

If you called the same model from C# you would use spaces.

0 Kudos