Esempio n. 1
0
def setupEnv():
    print "run at "+ str(datetime.datetime.now())
    rsel = "ENDDATE IS NULL"
    MakeTableView_management(resolve, "CCL_Resolution_tbl", rsel)
    CalculateField_management("CCL_Resolution_tbl", "CCL_LRS",  'str(!CITYNUMBER!)+str(!LRS_KEY![3:14])', "PYTHON" )
    MakeTableView_management(connection1+"CCL_Resolution", "CCL_Resolution_tbl10", 'CITYNUMBER<100')
    CalculateField_management("CCL_Resolution_tbl10", "CCL_LRS", '"0"+str(!CITYNUMBER!)+str(!LRS_KEY![3:14])', "PYTHON")
    MakeFeatureLayer_management(cntyroutelyr, "cmlrs")
    MakeFeatureLayer_management(stateroutelyr, "smlrs")
    MakeFeatureLayer_management(citylimits, "CityLimits", "TYPE IN ( 'CS', 'ON')")
    LocateFeaturesAlongRoutes_lr(citylimits,"cmlrs","LRS_KEY","0 Feet",connection1+"GIS_CITY","LRS_KEY LINE Beg_CMP End_CMP","FIRST","DISTANCE","NO_ZERO","FIELDS","M_DIRECTON")
    MakeRouteEventLayer_lr("cmlrs","LRS_KEY","CCL_Resolution_tbl","LRS_KEY LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE","City_Connecting_Links","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    MakeTableView_management(connection1+"GIS_CITY", "GIS_CITY")
    MakeTableView_management(laneclass, "LaneClass")
    MakeRouteEventLayer_lr("cmlrs","LRS_KEY","GIS_CITY","LRS_KEY LINE BEG_CMP END_CMP","GIS_BASED_CCL","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    OverlayRouteEvents_lr(connection1+"CCL_Resolution","LRS_KEY LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE",laneclass,"LRS_KEY LINE BCMP ECMP","INTERSECT",connection1+"CCL_LANE_CLASS_OVERLAY","LRS_KEY LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE","NO_ZERO","FIELDS","INDEX")
    print "create Route Layer specific to City Connecting Link locations"    
    FeatureClassToFeatureClass_conversion("City_Connecting_Links", connection0, "CITY_CONNECTING_LINK_CENTERLINE")
    LocateFeaturesAlongRoutes_lr(connection1+"CITY_CONNECTING_LINK_CENTERLINE",stateroutelyr,"LRS_ROUTE","0 Meters",connection1+"CCL_STATE_LRS_tbl","LRS_ROUTE LINE BEG_STATE_LOGMILE END_STATE_LOGMILE","FIRST","DISTANCE","ZERO","FIELDS","M_DIRECTON")
    MakeRouteEventLayer_lr("smlrs", "LRS_ROUTE",connection1+"CCL_STATE_LRS_tbl","LRS_ROUTE LINE BEG_STATE_LOGMILE END_STATE_LOGMILE","CCL_STATE_LRS","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    FeatureClassToFeatureClass_conversion("CCL_STATE_LRS", connection0, "CITY_CONNECTING_LINK_STATEREF")
    if Exists(connection1+"CITY_CONNECTING_LINK_STATE"):
        Delete_management(connection1+"CITY_CONNECTING_LINK_STATE")
    Dissolve_management(connection1+"CITY_CONNECTING_LINK_STATEREF",connection1+"CITY_CONNECTING_LINK_STATE","LRS_ROUTE;CITY;CITYNUMBER;DESCRIPTION;CCL_LRS","BEG_STATE_LOGMILE MIN;END_STATE_LOGMILE MAX","MULTI_PART","UNSPLIT_LINES")
    Dissolve_management(connection1+"CITY_CONNECTING_LINK_STATEREF",connection1+"CITY_CONNECTING_LINK_STATE_D","CCL_LRS","BEG_STATE_LOGMILE MIN;END_STATE_LOGMILE MAX","MULTI_PART","DISSOLVE_LINES")
    
    print "processes to Create the layer that will be used to create a new LRS for city connecting links"
Esempio n. 2
0
def NONSTATE_INT():
    print "add intersection points where state routes intersect non-state routes"
    MakeFeatureLayer_management(nonstate, 'NON_STATE_SYSTEM',
                                "CITYNUMBER IS NOT NULL AND CITYNUMBER<999")
    MakeFeatureLayer_management(connection1 + NewRoute, NewRoute)
    Intersect_analysis(
        "CCL_LRS_ROUTE #;'NON_STATE_SYSTEM' #",
        connection1 + "Intersect_NONSTATE", "ALL", "5 Feet", "POINT"
    )  #this doesnt reference the newroute variable, its easier that way
    MakeFeatureLayer_management(connection1 + "Intersect_NONSTATE", "NSI")
    LocateFeaturesAlongRoutes_lr("NSI", "CCL_LRS_ROUTE", NewRouteKey, "5 Feet",
                                 connection1 + "INTR_CCL_NS",
                                 "CCL_LRS POINT MEASURE", "ALL", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")
    MakeRouteEventLayer_lr("CCL_LRS_ROUTE", NewRouteKey,
                           connection1 + "INTR_CCL_NS",
                           "CCL_LRS POINT MEASURE", "INTR_CCL_NS Events", "#",
                           "ERROR_FIELD", "ANGLE_FIELD", "NORMAL", "ANGLE",
                           "LEFT", "POINT")
    AddField_management("INTR_CCL_NS Events", "CITY", "TEXT", "#", "#", "100")
    AddJoin_management("INTR_CCL_NS Events", "CITYNUMBER", citylimits,
                       "CITYNUMBER")
    #CalculateField_management("INTR_CCL_NS Events", schema+"INTR_CCL_NS_Features.CITY", "!GIS_DEV.CITY_LIMITS.CITY!", "PYTHON_9.3") #Preupdate
    CalculateField_management("INTR_CCL_NS Events",
                              schema + "INTR_CCL_NS_Features.CITY",
                              "!GIS.CITY_LIMITS.CITY!", "PYTHON_9.3")
    RemoveJoin_management("INTR_CCL_NS Events", "#")
    print "NonState_Int completed successfully."
Esempio n. 3
0
def FIMS_GIS(FMIS_ADD):
    #arcpy.MakeFeatureLayer_management(CPMSlyr, 'CPMS', ProjectSelect)
    #only process the new rows in FMIS_ADD

    MakeFeatureLayer_management(CPMSlyr, 'CPMS')
    MakeFeatureLayer_management(CountyLyr, 'County')
    MakeFeatureLayer_management(HPMSlyr, 'HPMS')
    MakeFeatureLayer_management(MPOLyr, 'MPO')
    MakeFeatureLayer_management(CONGDistlyr, 'CONG')
    MakeFeatureLayer_management(ws + "/Polygons", 'Polygons')
    #make the polygon analysis layer for Districts, Counties, and MPOs
    #arcpy.Union_analysis("CONG #;MPO #;County #",ws+"/Polygons","ALL","1 feet","GAPS")

    MakeTableView_management(FMIS_ADD, 'CPMS_STAGING_TMP')
    AddJoin_management("CPMS", "PROJECT_ID", "CPMS_STAGING_TMP",
                       "PROJECT_NUMBER", "KEEP_COMMON")

    Output_Event_Table_Properties = 'RID LINE CNTY_BEG CNTY_END'

    outtblP = ws + "/FIMS_EventTableAreas"
    outtblH = ws + "/FIMS_EventTableLines"

    if Exists(outtblP):
        Delete_management(outtblP)

    #consider/testing running "in memory"
    LocateFeaturesAlongRoutes_lr('CPMS', 'HPMS', "Route_ID", "30 Feet",
                                 outtblH, Output_Event_Table_Properties,
                                 "FIRST", "DISTANCE", "NO_ZERO", "FIELDS",
                                 "M_DIRECTON")
    MakeRouteEventLayer_lr("HPMS", "Route_ID", "FIMS_EventTableLines",
                           "rid LINE CNTY_BEG CNTY_END",
                           "FIMS_EventTableLineLyr", "#", "ERROR_FIELD",
                           "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT",
                           "POINT")
    Intersect_analysis("FIMS_EventTableLineLyr #;HPMS #;Polygons #",
                       ws + "/FMIS_Data", "ALL", "#", "LINE")

    Dissolve_management(
        "FMIS_Data", ws + r"/HPMS_Data",
        "PROJECT_ID;F_SYSTEM_V;NHS_VN;DISTRICT_1;COUNTY_NUMBER;ID_1", "#",
        "MULTI_PART", "UNSPLIT_LINES")
    # Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
    LocateFeaturesAlongRoutes_lr("HPMS_Data", "HPMS", "Route_ID", "0 Feet",
                                 ws + "/FIMS_EventTable",
                                 "RID LINE CNTY_BEG CNTY_END", "FIRST",
                                 "DISTANCE", "NO_ZERO", "FIELDS", "M_DIRECTON")
Esempio n. 4
0
def Maintenance():
    print "reference maintenance agreement table"
    MakeTableView_management(maintenance, "Maint_tview")
    MakeRouteEventLayer_lr(cntyroutelyr,"LRS_KEY", "Maint_tview","LRSKEY LINE BEGMILEPOST END_MP","Maintenance_Events_CNTY","#","ERROR_FIELD","ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    if Exists(connection1+"MAINTENANCE_CCL"):
        Delete_management(connection1+"MAINTENANCE_CCL")
    LocateFeaturesAlongRoutes_lr("Maintenance_Events_CNTY",connection1+"CCL_LRS_ROUTE",NewRouteKey,"1 Feet",connection1+"MAINTENANCE_CCL","CCL_LRS LINE CCL_BEGIN CCL_END","ALL","DISTANCE","ZERO","FIELDS","M_DIRECTON")
    print "show lane classification referenced to city connecting link LRS"
Esempio n. 5
0
def DirectionalUrbanClass():
    #do the same as for State Sys but for Non State Urban Classified Highways (Nusys)
    FeatureVerticesToPoints_management("RoadCenterlinesC",
                                       "in_memory/UrbanPoints", "MID")
    FeatureClassToFeatureClass_conversion(
        NSND,
        "in_memory",
        "NSND_NPD",
        where_clause="NETWORK_DIRECTION IN ( 'SB' , 'WB' )")
    LocateFeaturesAlongRoutes_lr("UrbanPoints", "NSND_NPD", "NE_UNIQUE",
                                 "200 Feet", "in_memory/UrbanPointsMeasures",
                                 "RID POINT MEAS", "ALL", "DISTANCE", "ZERO",
                                 "FIELDS", "M_DIRECTON")
    Delete_management("UrbanPoints")
    #is the query stil valid for non state system?  Explore hte NE Unique.  State System did not use the county number prefix

    SelectLayerByAttribute_management(
        "UrbanPointsMeasures", "NEW_SELECTION",
        """SUBSTRING( "RID", 4, 7) NOT  LIKE SUBSTRING("NON_State_System_LRSKey" ,4, 7)"""
    )

    DeleteRows_management(in_rows="UrbanPointsMeasures")
    MakeRouteEventLayer_lr("NSND_NPD",
                           "NE_UNIQUE",
                           "UrbanPointsMeasures",
                           "rid POINT MEAS",
                           "UrbanPointEvents",
                           offset_field="Distance",
                           add_error_field="ERROR_FIELD",
                           add_angle_field="ANGLE_FIELD",
                           angle_type="NORMAL",
                           complement_angle="ANGLE",
                           offset_direction="RIGHT",
                           point_event_type="POINT")
    MakeFeatureLayer_management("UrbanPointEvents", "UNPD_ID",
                                """"Distance">=0""")
    SelectLayerByLocation_management("UNPD_ID", "INTERSECT",
                                     "RoadCenterlinesC", "1 Feet",
                                     "NEW_SELECTION")

    #at this point, there are a lot of false positives, places with single carriagway roads and nusys divided
    #we need to incorporate the check overlap process to identify where their are single and dual carriagways here
    #starting with the technique to find sausages or dual carraigeways
    #SpatialJoin_analysis("UNPD_ID", "RoadCenterlinesC", "in_memory/ValidateSausages120", "JOIN_ONE_TO_ONE", "KEEP_ALL", '#', "INTERSECT", "120 Feet", "Distance")

    #this Spatial Join step is improving the results, removing most false positives.  It still shows overlapping segments
    #it would be improved even more, potentially, by testing the non-primary direction against dissolve somehow.
    #except, the calculate method is by segment to the source, a dissolve would complicate the process of calculating back to the source data
    #we are looking for count grater than 0 of the offset point to hte segment, so a dissolved segment should work
    import EliminateOverlaps
    from EliminateOverlaps import CollectorDissolve
    #set the roadcenterline input and dissolve output for RoadCenterline dissolve for this subroutine
    roadcenterlines = "RoadCenterlinesC"
    ClassOutput = r"in_memory/RMC2"
    CollectorDissolve()
    SpatialJoin_analysis("UNPD_ID", "RMC2dissolve",
                         "in_memory/ValidateSausages120", "JOIN_ONE_TO_ONE",
                         "KEEP_ALL", '#', "INTERSECT", "120 Feet", "Distance")
Esempio n. 6
0
def Report():
    OverlayRouteEvents_lr(
        connection1 + "MAINTENANCE_CCL", "CCL_LRS LINE CCL_BEGIN CCL_END",
        connection1 + "LANECLASS_CCL", "CCL_LRS LINE CCL_BEGIN CCL_END",
        "UNION", connection1 + "CCL_Report_M",
        "CCL_LRS LINE CCL_MA_BEGIN CCL_MA_END", "NO_ZERO", "FIELDS", "INDEX")
    DissolveRouteEvents_lr(connection1 + "CCL_Report_M",
                           "CCL_LRS LINE CCL_MA_BEGIN CCL_MA_END",
                           "CITYNO;MAINT_DESC;CITY_NAME;Lanes",
                           connection1 + "CCL_Report_D",
                           "CCL_LRS LINE CCL_MA_BEGIN CCL_MA_END",
                           "CONCATENATE", "INDEX")
    #cleanup border errors - make feature layers based on City, city number, and CCLLRS and delete where they are not consistent between Maintenance and Resolution sections
    if Exists(connection1 + "CCL_Report"):
        MakeTableView_management(connection1 + "CCL_Report", "Report_Clean1",
                                 "CCL_LRS2 <> CCL_LRS")
        DeleteRows_management("Report_Clean1")
    LocateFeaturesAlongRoutes_lr(LineFeatureClass,
                                 connection1 + "CCL_LRS_ROUTE", NewRouteKey,
                                 "#", connection1 + "RES_SECTION_CCL",
                                 "CCL_LRS LINE CCL_BEGIN CCL_END", "ALL",
                                 "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
    OverlayRouteEvents_lr(
        connection1 + "RES_SECTION_CCL", "CCL_LRS LINE CCL_BEGIN CCL_END",
        connection1 + "CCL_Report_D", "CCL_LRS LINE CCL_MA_BEGIN CCL_MA_END",
        "INTERSECT", connection1 + "CCL_Report",
        "CCL_LRS LINE CCL_BEGIN CCL_END", "NO_ZERO", "FIELDS", "INDEX")
    MakeRouteEventLayer_lr(connection1 + "CCL_LRS_ROUTE", "CCL_LRS",
                           connection1 + "CCL_Report",
                           "CCL_LRS LINE CCL_BEGIN CCL_END",
                           "City Connecting Links Mapping", "#", "ERROR_FIELD",
                           "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT",
                           "POINT")
    print "add mapping fields for lane miles"
    AddField_management("City Connecting Links Mapping", "CenterlineMiles",
                        "DOUBLE")
    CalculateField_management("City Connecting Links Mapping",
                              "CenterlineMiles", '[CCL_END]-[CCL_BEGIN]', "VB")
    AddField_management("City Connecting Links Mapping", "LaneMiles", "DOUBLE")
    CalculateField_management("City Connecting Links Mapping", "LaneMiles",
                              '([CCL_END]-[CCL_BEGIN])*[Lanes]', "VB")
    AddField_management(connection1 + "CITY_CONNECTING_LINK_CENTERLINE",
                        "CenterlineMiles", "DOUBLE")
    MakeFeatureLayer_management(
        connection1 + "CITY_CONNECTING_LINK_CENTERLINE", 'Res_centerline')
    CalculateField_management("Res_centerline", "CenterlineMiles",
                              '[END_CNTY_LOGMILE]-[BEG_CNTY_LOGMILE]', "VB")
    Dissolve_management("Res_centerline", connection1 + "CCL_LEGEND",
                        "CITY;LRS_KEY;CITYNUMBER;CCL_LRS",
                        "CenterlineMiles SUM", "MULTI_PART", "DISSOLVE_LINES")
    AddField_management(connection1 + "CCL_LEGEND", "CCL_LEGEND", "TEXT", "#",
                        "#", "50")
    legendexp = 'str(!CCL_LRS![3]) +"-" + str(!CCL_LRS![6:9]).lstrip("0")+"........"+ str(!SUM_CenterlineMiles!)'
    MakeFeatureLayer_management(connection1 + "CCL_LEGEND", 'LegendCalc')
    CalculateField_management("LegendCalc", "CCL_LEGEND", legendexp,
                              "PYTHON_9.3", "#")
Esempio n. 7
0
def LaneClass():
    MakeFeatureLayer_management(laneclass, 'LNCL',
                                "LANE_DIRECTION in ( 'EB' , 'NB' )")
    LocateFeaturesAlongRoutes_lr("LNCL", connection1 + "CCL_LRS_ROUTE",
                                 NewRouteKey, "0.1 FEET",
                                 connection1 + "LANECLASS_CCL",
                                 "CCL_LRS LINE CCL_BEGIN CCL_END", "ALL",
                                 "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
    AddField_management(connection1 + "LANECLASS_CCL", "Lanes", "LONG")
    MakeTableView_management(laneclass, "LANECLASS_CCL_tbl",
                             "LANE_DIRECTION in ( 'EB' , 'NB' )")
    CalculateField_management(connection1 + "LANECLASS_CCL", "Lanes",
                              'Left([LNCL_CLS_ID_DESC],1)', "VB")
Esempio n. 8
0
def Create_CCL_Calibration_Points():
    # Intersect GIS.City_Limits with SMLRS to obtain points layer
    # write to file geodatabase.
    MakeFeatureLayer_management(stateroutelyr, "smlrs_d")
    MakeFeatureLayer_management(citylimits, "citylimits_d",
                                "TYPE IN ( 'CS', 'ON')")
    intersectFeaures = ["smlrs_d", "citylimits_d"]
    print "Intersecting State Routes and City Limits"
    Intersect_analysis(intersectFeaures,
                       r"D:\workspaces\pythontests.gdb\cal_points_multi",
                       "NO_FID", "", "point")

    # Split the multipoint features into single points and place in another layer.
    print "Splitting multipart points into single points."
    MultipartToSinglepart_management(
        r"D:\workspaces\pythontests.gdb\cal_points_multi",
        r"D:\workspaces\pythontests.gdb\cal_points_simple")

    # Clean the simple points layer by removing extraneous fields.

    # Locate the created points layer along the SMLRS routes to
    # generate a table with measurements.
    print "Locating the edge of city boundary points along the state system."
    reloc_properties = "point_LRS POINT point_Loc"

    #fieldList = ListFields("smlrs_d")
    #for field in fieldList:
    #print str(field.name)

    LocateFeaturesAlongRoutes_lr(
        r"D:\workspaces\pythontests.gdb\cal_points_simple", "smlrs_d",
        "LRS_ROUTE", "10 Feet",
        r"D:\workspaces\pythontests.gdb\cal_points_reloc", reloc_properties,
        "FIRST", "NO_DISTANCE", "NO_ZERO", "NO_FIELDS")

    point_Properties = "point_LRS POINT point_Loc"
    MakeRouteEventLayer_lr("smlrs_d", "LRS_ROUTE",
                           r"D:\workspaces\pythontests.gdb\cal_points_reloc",
                           point_Properties, "new_point_locations")

    CopyFeatures_management(
        "new_point_locations",
        r"D:\workspaces\pythontests.gdb\CCL_Point_Calibrators")

    # Use this set of points as the calibration points for the
    # CCL_LRS_ROUTE layer's calibration.

    # Add the measure values to the points layer so that it can be
    # used to calibrate the measures of the CCL_LRS routes.
    print "Calibration Points created."
Esempio n. 9
0
def CheckRouteShapeLength():
    print "creating Non_State_Routes by the Shape Length"
    MakeFeatureLayer_management("C:/temp/Nusys_Check.gdb/Non_State_Classified", "BackwardSegs", "LRS_BACKWARDS = -1 AND MILEAGE_COUNTED = -1")
    FlipLine_edit("BackwardSegs") 
    Dissolve_management("Non_State_Classified", "C:/TEMP/Nusys_Check.gdb/TotalRouteShapeLength", "LRS_KEY", "", "MULTI_PART", "DISSOLVE_LINES")
    AddField_management("TotalRouteShapeLength", "Mileage", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("TotalRouteShapeLength", "Mileage", "Round([LINEARGEOMETRY_Length] /5280, 3)", "VB", "")
    AddField_management("TotalRouteShapeLength", "Zero", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("TotalRouteShapeLength", "Zero", "0", "VB", "")

    #MakeFeatureLayer_management(in_features="C:/temp/Nusys_Check.gdb/TotalRouteShapeLength", out_layer="ForwardRoutes", where_clause="LRS_BACKWARDS = 0")

    CreateRoutes_lr("TotalRouteShapeLength", "LRS_KEY", destdb+"\ShapeLengthRoute", "TWO_FIELDS", "Zero", "Mileage", "UPPER_LEFT", "1", "0", "IGNORE", "INDEX")
    #Flip them back to the original direction
    FlipLine_edit(in_features="BackwardSegs") 
    LocateFeaturesAlongRoutes_lr("Non_State_Classified", "ShapeLengthRoute", "LRS_KEY", "0 Feet", "C:/temp/Nusys_Check.gdb/NON_STATE_EVENTS", "RID LINE FMEAS TMEAS", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
    AddField_management("NON_STATE_EVENTS", "CheckBegin", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("NON_STATE_EVENTS", "CheckEnd", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    
    CalculateField_management("NON_STATE_EVENTS", "CheckBegin", "abs(!LRS_BEG_CNTY_LOGMILE!- !FMEAS!)", "PYTHON_9.3", "")
    CalculateField_management("NON_STATE_EVENTS", "CheckEnd", "abs(!LRS_END_CNTY_LOGMILE!- !TMEAS!)", "PYTHON_9.3", "")
   
    MakeRouteEventLayer_lr("ShapeLengthRoute", "LRS_KEY", "NON_STATE_EVENTS", "rid LINE fmeas tmeas", "LRS_Review_Events", "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
Esempio n. 10
0
def STATE_INT():
    print "add intersect intersection points that are state - state intersections and interchanges"
    MakeFeatureLayer_management(interchange, 'INTR', "ON_STATE_NONSTATE = 'S'")
    LocateFeaturesAlongRoutes_lr("INTR", "CCL_LRS_ROUTE", NewRouteKey,
                                 "5 Feet", connection1 + "INTR_CCL",
                                 "CCL_LRS POINT MEASURE", "ALL", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")
    MakeRouteEventLayer_lr("CCL_LRS_ROUTE", NewRouteKey,
                           connection1 + "INTR_CCL", "CCL_LRS POINT MEASURE",
                           "INTR_CCL_Events", "#", "ERROR_FIELD",
                           "ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
    AddField_management("INTR_CCL_Events", "CITY", "TEXT", "#", "#", "100")
    AddField_management("INTR_CCL_Events", "CITYNUMBER", "Long", "#", "#", "#")
    CalculateField_management("INTR_CCL_Events", "CITYNUMBER",
                              "int(!CCL_LRS![0:3])", "PYTHON_9.3")
    AddJoin_management("INTR_CCL_Events", "CITYNUMBER", citylimits,
                       "CITYNUMBER")
    #CalculateField_management("INTR_CCL_Events", schema+"INTR_CCL_Features.CITY", "!GIS_DEV.CITY_LIMITS.CITY!", "PYTHON_9.3") #Preupdate
    CalculateField_management("INTR_CCL_Events",
                              schema + "INTR_CCL_Features.CITY",
                              "!GIS.CITY_LIMITS.CITY!", "PYTHON_9.3")
    RemoveJoin_management("INTR_CCL_Events", "#")
    print "State_Int completed successfully."
Esempio n. 11
0
def CheckCRouteShapeLength():
    print "CreateNUSYSLocal() is a prerequisite function to this one "
    print "creating Non_State_Routes by the Shape Length"
    MakeFeatureLayer_management("C:/temp/Nusys_Check.gdb/Non_State_Classified", "BackwardSegs", "LRS_BACKWARDS = -1 AND (MILEAGE_COUNTED = -1 OR SURFACE = 'Propose')")
    FlipLine_edit("BackwardSegs") 
    Dissolve_management("Non_State_Classified", "C:/TEMP/Nusys_Check.gdb/TotalRouteShapeLength", "LRS_KEY", "", "MULTI_PART", "DISSOLVE_LINES")
    AddField_management("TotalRouteShapeLength", "Mileage", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("TotalRouteShapeLength", "Mileage", "Round([Lineargeometry_Length] /5280, 3)", "VB", "")
    AddField_management("TotalRouteShapeLength", "Zero", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("TotalRouteShapeLength", "Zero", "0", "VB", "")

    #MakeFeatureLayer_management(in_features="C:/temp/Nusys_Check.gdb/TotalRouteShapeLength", out_layer="ForwardRoutes", where_clause="LRS_BACKWARDS = 0")

    CreateRoutes_lr("TotalRouteShapeLength", "LRS_KEY", destdb+"\C_ShapeLengthRoute", "TWO_FIELDS", "Zero", "Mileage", "UPPER_LEFT", "1", "0", "IGNORE", "INDEX")
    #Flip them back to the original direction
    FlipLine_edit(in_features="BackwardSegs") 
    LocateFeaturesAlongRoutes_lr("Non_State_Classified", "ShapeLengthRoute", "LRS_KEY", "0 Feet", "C:/temp/Nusys_Check.gdb/C_NON_STATE_EVENTS", "RID LINE FMEAS TMEAS", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
    AddField_management("C_NON_STATE_EVENTS", "AdjBegin", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("C_NON_STATE_EVENTS", "AdjEnd", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("C_NON_STATE_EVENTS", "CHG_BEGLOG","DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("C_NON_STATE_EVENTS", "CHG_ENDLOG","DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("C_NON_STATE_EVENTS", "NEW_BEGLOG","DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("C_NON_STATE_EVENTS", "NEW_ENDLOG","DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("C_NON_STATE_EVENTS", "AdjLength","DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("C_NON_STATE_EVENTS", "CHANGE","DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="AdjBegin", expression="round( !FMEAS! , 3 )", expression_type="PYTHON_9.3", code_block="")
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="AdjEnd", expression="round( !TMEAS! , 3 )", expression_type="PYTHON_9.3", code_block="")
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="CHG_BEGLOG", expression="[AdjBegin] - [LRS_BEG_CNTY_LOGMILE]", expression_type="VB", code_block="")
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="CHG_ENDLOG", expression="[AdjEnd] - [LRS_END_CNTY_LOGMILE]", expression_type="VB", code_block="")
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="NEW_BEGLOG", expression="[AdjBegin]", expression_type="VB", code_block="")
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="NEW_ENDLOG", expression="[AdjEnd]", expression_type="VB", code_block="")
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="AdjLength", expression="[AdjEnd] - [AdjBegin]", expression_type="VB", code_block="")
    CalculateField_management(in_table="C_NON_STATE_EVENTS", field="CHANGE", expression="abs([LENGTH] - [AdjLength])", expression_type="VB", code_block="")
       
    MakeRouteEventLayer_lr("C_ShapeLengthRoute", "LRS_KEY", "C_NON_STATE_EVENTS", "rid LINE fmeas tmeas", "C_LRS_Review_Events", "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
Esempio n. 12
0
def FIMS_GIS():
    #arcpy.MakeFeatureLayer_management(CPMSlyr, 'CPMS', ProjectSelect)

    MakeFeatureLayer_management(CPMSlyr, 'CPMS')
    MakeFeatureLayer_management(CountyLyr, 'County')
    MakeFeatureLayer_management(HPMSlyr, 'HPMS')
    MakeFeatureLayer_management(MPOLyr, 'MPO')
    MakeFeatureLayer_management(CONGDistlyr, 'CONG')
    MakeFeatureLayer_management(ws + "/Polygons", 'Polygons')
    MakeTableView_management(deltbl, 'DeleteView')
    MakeTableView_management(newtbl, 'InsertView')
    #make the polygon analysis layer for Districts, Counties, and MPOs
    #arcpy.Union_analysis("CONG #;MPO #;County #",ws+"/Polygons","ALL","1 feet","GAPS")
    # Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
    # The following inputs are layers or table views: "CPMS", "CPMS.CPMS_STAGING_TMP"
    MakeTableView_management(FMIS_PROJ, "CPMS_STAGING_TMP")
    AddJoin_management("CPMS", "PROJECT_ID", "InsertView", "PROJECT_NUMBER",
                       "KEEP_COMMON")

    Output_Event_Table_Properties = 'RID LINE CNTY_BEG CNTY_END'

    outtblH = ws + "/FIMS_EventTableLines"

    if Exists(outtblH):
        Delete_management(outtblH)

    print "locating CPMS to HPMS route"
    LocateFeaturesAlongRoutes_lr('CPMS', 'HPMS', "Route_ID", "0 miles",
                                 outtblH, Output_Event_Table_Properties,
                                 "FIRST", "DISTANCE", "NO_ZERO", "FIELDS",
                                 "M_DIRECTON")
    #the 30 foot tolerance we allowed here also created a bunch of 30' segments at project intersections.  Those should be handled.
    #...Or the locate tolerance changed to 0
    #cleansel = "RID <> CRND_RTE" #is thisnot the right way to handle this, because it will delete the short segments crossing the GIS county boundary?  not really
    #selection statement deleted non-state highway system might be better
    #MakeTableView_management(outtblH, "cleanup", cleansel)
    #DeleteRows_management("cleanup")

    MakeRouteEventLayer_lr("HPMS", "Route_ID", ws + "/FIMS_EventTableLines",
                           "rid LINE CNTY_BEG CNTY_END",
                           "FIMS_EventTableLineLyr", "#", "ERROR_FIELD",
                           "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT",
                           "POINT")

    print "Intersection routes to areas"
    Intersect_analysis("FIMS_EventTableLineLyr #;HPMS #;Polygons #",
                       ws + "/FMIS_Data", "ALL", "#", "LINE")

    if Exists(ws + "/HPMS_DataD"):
        Delete_management(ws + "/HPMS_DataD")

    Dissolve_management(
        ws + "/FMIS_Data", ws + "/HPMS_DataD",
        "PROJECT_ID;F_SYSTEM_V;NHS_VN;DISTRICT_1;COUNTY_NUMBER;ID_1", "#",
        "MULTI_PART", "UNSPLIT_LINES")
    # Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
    print "locating processed data to HPMS mileage"

    if Exists(ws + "/FIMS_EventTable"):
        Delete_management(ws + "/FIMS_EventTable")

    LocateFeaturesAlongRoutes_lr(ws + "/HPMS_DataD", "HPMS", "Route_ID",
                                 "0 miles", ws + "/FIMS_EventTable",
                                 "RID LINE CNTY_BEG CNTY_END", "FIRST",
                                 "DISTANCE", "NO_ZERO", "FIELDS", "M_DIRECTON")
    #MaleTableView(ws+"/FIMS_EventTable", )

    Append_management(
        ws + "/FIMS_EventTable", FMIS_LOAD, "NO_TEST",
        """ROUTE_ID "ROUTE_ID" true true false 14 Text 0 0 ,First,#,FIMS_EventTable,RID,-1,-1;BEG_CNTY_MP "BEG_CNTY_MP" true true false 8 Double 10 38 ,First,#,FIMS_EventTable,CNTY_BEG,-1,-1;END_CNTY_MP "END_CNTY_MP" true true false 8 Double 10 38 ,First,#,FIMS_EventTable,CNTY_END,-1,-1;CONGRESSIONAL_DISTRICT "CONGRESSIONAL_DISTRICT" true true false 50 Text 0 0 ,First,#,FIMS_EventTable,DISTRICT_1,-1,-1;URBAN_ID "URBAN_ID" true true false 10 Text 0 0 ,First,#,FIMS_EventTable,ID_1,-1,-1;FUN_CLASS "FUN_CLASS" true true false 3 Text 0 0 ,First,#,FIMS_EventTable,F_SYSTEM_V,-1,-1;SYSTEM_CODE "SYSTEM_CODE" true true false 10 Text 0 0 ,First,#,FIMS_EventTable,NHS_VN,-1,-1;PROJECT_NUMBER "PROJECT_NUMBER" true true false 15 Text 0 0 ,First,#,FIMS_EventTable,PROJECT_ID,-1,-1;COUNTY "COUNTY" true true false 3 Text 0 0 ,First,#,FIMS_EventTable,COUNTY_NUMBER,-1,-1""",
        "#")

    print "Rows appended to CPMS Load Table CPMS_HPMS_FMIS_DATA"
Esempio n. 13
0
def CRB():
    print "querying the shared.NON_STATE_SYSTEM to obtain only urban classified primary C routes with mileage that should be counted and for resolution segments."
    MakeFeatureLayer_management(
        NonState, "NonStateCP",
        "((LRS_KEY LIKE '%C%' OR LRS_ROUTE_PREFIX = 'C') AND (MILEAGE_COUNTED = -1)) OR (LRS_DIR_OF_TRAVEL = 'P' and SURFACE = 'Propose')"
    )

    print "querying the shared.NON_STATE_SYSTEM to obtain only urban classified NonPrimary C routes with mileage that should be counted and for resolution segments."
    MakeFeatureLayer_management(
        NonState, "NonStateCNP",
        "(LRS_KEY LIKE '%C%' OR LRS_ROUTE_PREFIX = 'C') AND (MILEAGE_COUNTED = 0) AND (LRS_DIR_OF_TRAVEL = 'S') and (COUNTY_NUMBER <> 0)"
    )

    print "shared.Non_State_System has unique IDS that we desire to keep as persistent IDs for comparison with GeoMedia, so we are spatially intersecting the state boundary to keep them as is."
    Buffer_analysis(StateBnd, "State_Boundary_1Mile", "5280 Feet", "FULL",
                    "ROUND", "NONE", "", "PLANAR")
    MakeFeatureLayer_management("State_Boundary_1Mile", "StateBnd")
    Intersect_analysis("NonStateCP #;StateBnd #",
                       "Non_State_Classified_Primary", "ALL", "-1 Unknown",
                       "LINE")
    Intersect_analysis("NonStateCNP #;StateBnd #",
                       "Non_State_Classified_NonPrimary", "ALL", "-1 Unknown",
                       "LINE")

    NonStateCP_fx = r'Non_State_Classified_Primary'
    NonStateCNP_fx = r'Non_State_Classified_NonPrimary'

    MakeFeatureLayer_management(NonStateCP_fx, "Non_State_Classified_Primary")
    MakeFeatureLayer_management(NonStateCNP_fx,
                                "Non_State_Classified_NonPrimary")

    CP_ET = 'CP_NON_STATE_EVENTS'
    CNP_ET = 'CNP_NON_STATE_EVENTS'

    MakeFeatureLayer_management(NUSYS, "Nusys_Extract",
                                "NSEC_SUB_CLASS <> 'R'")

    print "creating primary C Non_State_Routes by the Shape Length"
    MakeFeatureLayer_management(
        "Non_State_Classified_Primary", "BackwardSegsCP",
        "LRS_BACKWARDS = -1 AND (MILEAGE_COUNTED = -1 OR (LRS_DIR_OF_TRAVEL = 'P' and SURFACE = 'Propose'))"
    )
    FlipLine_edit("BackwardSegsCP")
    Dissolve_management("Non_State_Classified_Primary", "CPRouteShapeLength",
                        "NQR_DESCRIPTION", "", "MULTI_PART", "DISSOLVE_LINES")
    AddField_management("CPRouteShapeLength", "BCM", "DOUBLE", "", "", "", "",
                        "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("CPRouteShapeLength", "BCM", "0", "VB", "")
    AddField_management("CPRouteShapeLength", "ECM", "DOUBLE", "", "", "", "",
                        "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("CPRouteShapeLength", "ECM",
                              "!Shape.length@miles!", "Python")

    CreateRoutes_lr("CPRouteShapeLength", "NQR_DESCRIPTION",
                    destdb + "\CP_ShapeLengthRoute", "TWO_FIELDS", "BCM",
                    "ECM", "UPPER_LEFT", "1", "0", "IGNORE", "INDEX")
    #Flip them back to the original direction
    FlipLine_edit(in_features="BackwardSegsCP")
    LocateFeaturesAlongRoutes_lr("Non_State_Classified_Primary",
                                 "CP_ShapeLengthRoute", "NQR_DESCRIPTION",
                                 "0 Feet", "CP_NON_STATE_EVENTS",
                                 "RID LINE FMEAS TMEAS", "FIRST", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")
    AddField_management("CP_NON_STATE_EVENTS", "AdjBegin", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CP_NON_STATE_EVENTS", "AdjEnd", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CP_NON_STATE_EVENTS", "CHG_BEGLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CP_NON_STATE_EVENTS", "CHG_ENDLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CP_NON_STATE_EVENTS", "NEW_BEGLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CP_NON_STATE_EVENTS", "NEW_ENDLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CP_NON_STATE_EVENTS", "AdjLength", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CP_NON_STATE_EVENTS", "CHANGE", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")

    CalculateField_management("CP_NON_STATE_EVENTS",
                              "AdjBegin",
                              "round( [FMEAS] , 3 )",
                              "VB",
                              code_block="")
    CalculateField_management("CP_NON_STATE_EVENTS",
                              "AdjEnd",
                              "round( [TMEAS] , 3 )",
                              "VB",
                              code_block="")
    CalculateField_management("CP_NON_STATE_EVENTS",
                              "CHG_BEGLOG",
                              "[AdjBegin] - [LRS_BEG_CNTY_LOGMILE]",
                              "VB",
                              code_block="")
    CalculateField_management("CP_NON_STATE_EVENTS",
                              "CHG_ENDLOG",
                              "[AdjEnd] - [LRS_END_CNTY_LOGMILE]",
                              "VB",
                              code_block="")
    CalculateField_management("CP_NON_STATE_EVENTS",
                              "NEW_BEGLOG",
                              "[AdjBegin]",
                              "VB",
                              code_block="")
    CalculateField_management("CP_NON_STATE_EVENTS",
                              "NEW_ENDLOG",
                              "[AdjEnd]",
                              "VB",
                              code_block="")
    CalculateField_management("CP_NON_STATE_EVENTS",
                              "AdjLength",
                              "[AdjEnd] - [AdjBegin]",
                              "VB",
                              code_block="")
    CalculateField_management("CP_NON_STATE_EVENTS",
                              "CHANGE",
                              "abs([LENGTH] - [AdjLength])",
                              "VB",
                              code_block="")

    MakeRouteEventLayer_lr("CP_ShapeLengthRoute", "NQR_DESCRIPTION",
                           "CP_NON_STATE_EVENTS", "RID LINE FMEAS TMEAS",
                           "CP_LRS_Review_Events", "", "ERROR_FIELD",
                           "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT",
                           "POINT")
    print "CP-Rte Builder script completed successfully"

    print "creating NonPrimary C Non_State_Routes by the Shape Length"
    MakeFeatureLayer_management(
        "Non_State_Classified_NonPrimary", "BackwardSegsCNP",
        "LRS_BACKWARDS = -1 AND LRS_DIR_OF_TRAVEL = 'S' and COUNTY_NUMBER <> 0"
    )
    FlipLine_edit("BackwardSegsCNP")
    Dissolve_management("Non_State_Classified_NonPrimary",
                        "CNPRouteShapeLength", "LRS_KEY", "", "MULTI_PART",
                        "DISSOLVE_LINES")
    AddField_management("CNPRouteShapeLength", "BCM", "DOUBLE", "", "", "", "",
                        "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("CNPRouteShapeLength", "BCM", "0", "VB", "")
    AddField_management("CNPRouteShapeLength", "ECM", "DOUBLE", "", "", "", "",
                        "NULLABLE", "NON_REQUIRED", "")
    CalculateField_management("CNPRouteShapeLength", "ECM",
                              "!Shape.length@miles!", "Python")

    CreateRoutes_lr("CNPRouteShapeLength", "LRS_KEY",
                    destdb + "\CNP_ShapeLengthRoute", "TWO_FIELDS", "BCM",
                    "ECM", "UPPER_LEFT", "1", "0", "IGNORE", "INDEX")
    #Flip them back to the original direction
    FlipLine_edit(in_features="BackwardSegsCNP")
    LocateFeaturesAlongRoutes_lr("Non_State_Classified_NonPrimary",
                                 "CNP_ShapeLengthRoute", "LRS_KEY", "0 Feet",
                                 "CNP_NON_STATE_EVENTS",
                                 "RID LINE FMEAS TMEAS", "FIRST", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")
    AddField_management("CNP_NON_STATE_EVENTS", "AdjBegin", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNP_NON_STATE_EVENTS", "AdjEnd", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNP_NON_STATE_EVENTS", "CHG_BEGLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNP_NON_STATE_EVENTS", "CHG_ENDLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNP_NON_STATE_EVENTS", "NEW_BEGLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNP_NON_STATE_EVENTS", "NEW_ENDLOG", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNP_NON_STATE_EVENTS", "AdjLength", "DOUBLE", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNP_NON_STATE_EVENTS", "CHANGE", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")

    CalculateField_management("CNP_NON_STATE_EVENTS", "AdjBegin",
                              "round( [FMEAS] , 3 )", "VB", "")
    CalculateField_management("CNP_NON_STATE_EVENTS", "AdjEnd",
                              "round( [TMEAS] , 3 )", "VB", "")
    CalculateField_management("CNP_NON_STATE_EVENTS", "CHG_BEGLOG",
                              "[AdjBegin] - [LRS_BEG_CNTY_LOGMILE]", "VB", "")
    CalculateField_management("CNP_NON_STATE_EVENTS", "CHG_ENDLOG",
                              "[AdjEnd] - [LRS_END_CNTY_LOGMILE]", "VB", "")
    CalculateField_management("CNP_NON_STATE_EVENTS", "NEW_BEGLOG",
                              "[AdjBegin]", "VB", "")
    CalculateField_management("CNP_NON_STATE_EVENTS", "NEW_ENDLOG", "[AdjEnd]",
                              "VB", "")

    CalculateField_management("CNP_NON_STATE_EVENTS",
                              "AdjLength",
                              "[AdjEnd] - [AdjBegin]",
                              "VB",
                              code_block="")
    CalculateField_management("CNP_NON_STATE_EVENTS",
                              "CHANGE",
                              "abs([LENGTH] - [AdjLength])",
                              "VB",
                              code_block="")

    MakeRouteEventLayer_lr("CNP_ShapeLengthRoute", "LRS_KEY",
                           "CNP_NON_STATE_EVENTS", "RID LINE FMEAS TMEAS",
                           "CNP_LRS_Review_Events", "", "ERROR_FIELD",
                           "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT",
                           "POINT")
    AddField_management("CNPRouteShapeLength", "PersistentID", "LONG", "", "",
                        "", "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNPRouteShapeLength", "Pbeg", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNPRouteShapeLength", "Pend", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")

    CalculateField_management("CNPRouteShapeLength", "PersistentID", "!ID2!",
                              "PYTHON_9.3", "")
    TableToTable_conversion("CNPRouteShapeLength", "in_memory", "CNP_Events",
                            "")

    endpoints = ["beg", "end"]
    for pos in endpoints:
        out_event = "CNP_Events_" + pos
        print out_event
        out_lyr = "CNP_Events_Features_" + pos
        print out_lyr

        outfield = "P" + pos
        print outfield
        if pos == "beg":
            print "Will locate begin point"
            routesettings = "LRS_KEY POINT BCM"
        else:
            print "locating end point"
            routesettings = "LRS_KEY POINT ECM"
        MakeRouteEventLayer_lr("CNP_ShapeLengthRoute", "LRS_KEY", "CNP_Events",
                               routesettings, out_event, "", "ERROR_FIELD",
                               "ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT",
                               "POINT")
        LocateFeaturesAlongRoutes_lr(out_event, "CP_ShapeLengthRoute",
                                     "NQR_DESCRIPTION", "500 Feet", out_lyr,
                                     "RID POINT MEAS", "ALL", "DISTANCE",
                                     "ZERO", "FIELDS", "M_DIRECTON")
        AddJoin_management(out_lyr, "PersistentID", "CNPRouteShapeLength",
                           "PersistentID", "KEEP_ALL")
        selexp = out_lyr + ".RID <> CNPRouteShapeLength.LRS_KEY"
        print selexp
        SelectLayerByAttribute_management(out_lyr, "NEW_SELECTION", selexp)
        DeleteRows_management(out_lyr)
        RemoveJoin_management(out_lyr)
        AddJoin_management("CNPRouteShapeLength", "PersistentID", out_lyr,
                           "PersistentID", "KEEP_ALL")
        #expression = "[CNP_Events_Features_Begin.MEAS]"
        expression = "[" + out_lyr + ".MEAS]"
        print expression
        calcfield = "CNPRouteShapeLength." + outfield
        #CNPRouteShapeLength.Pbeg
        CalculateField_management("CNPRouteShapeLength", calcfield, expression,
                                  "VB", "")
        RemoveJoin_management("CNPRouteShapeLength", "")

    #test flipped routes and calculate mileage and flip flag
    AddField_management("CNPRouteShapeLength", "FlipTest", "LONG", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNPRouteShapeLength", "Adj_Beg", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")
    AddField_management("CNPRouteShapeLength", "Adj_End", "DOUBLE", "", "", "",
                        "", "NULLABLE", "NON_REQUIRED", "")
    SelectLayerByAttribute_management("CNPRouteShapeLength", "NEW_SELECTION",
                                      '"Pbeg" > "Pend"')
    CalculateField_management("CNPRouteShapeLength", "FlipTest", "1", "VB", "")
    CalculateField_management("CNPRouteShapeLength", "Adj_Beg", "!Pend!",
                              "Python", "")
    CalculateField_management("CNPRouteShapeLength", "Adj_End", "!Pbeg!",
                              "Python", "")
    SelectLayerByAttribute_management("CNPRouteShapeLength", "NEW_SELECTION",
                                      '"Pbeg" < "Pend"')
    CalculateField_management("CNPRouteShapeLength", "FlipTest", "0", "VB", "")
    CalculateField_management("CNPRouteShapeLength", "Adj_Beg", "!Pbeg!",
                              "Python", "")
    CalculateField_management("CNPRouteShapeLength", "Adj_End", "!Pend!",
                              "Python", "")
    SelectLayerByAttribute_management("CNPRouteShapeLength", "NEW_SELECTION",
                                      '"Adj_Beg" <= 0.003')
    CalculateField_management("CNPRouteShapeLength", "Adj_Beg", "0", "Python",
                              "")

    print "CNP-Rte Builder script completed successfully"
Esempio n. 14
0
Created on Aug 20, 2013
create a begin - end attribute network using segments for Precision Linear referencing by GeoMedia users 

@author: kyleg
'''

from arcpy import env, SplitLine_management, LocateFeaturesAlongRoutes_lr, CalculateField_management, TransformRouteEvents_lr, MakeRouteEventLayer_lr, FeatureClassToFeatureClass_conversion
from CONFIG import ws, tempgdb, XYResolution, XYTolerance, MResolution, MTolerance
operws = ws+"\\"+tempgdb+"\\"

env.XYResolution = XYResolution
env.XYTolerance = XYTolerance
env.MResolution = MResolution
env.MTolerance = MTolerance

print "tolerances  set, now proceeding to split the lines"

SplitLine_management(operws+"STATE_SYSTEM", operws+"STATE_SYSTEM_PREC") # 15 sec

output = ws+"\\"+tempgdb+'\LRM_CR_PART'
LocateFeaturesAlongRoutes_lr(operws+"STATE_SYSTEM_PREC",operws+"CMLRS","LRS_KEY","0 miles",output,"LRS_KEY LINE BEG_CNTY_LOGMILE2 END_CNTY_LOGMILE2","FIRST","DISTANCE","ZERO","FIELDS","M_DIRECTON")
print 'tried' + output + ' successfully' #4 minutes; 06/17/01 removed the 1 ft tolerance
CalculateField_management(operws+"LRM_CR_PART","BEG_CNTY_LOGMILE","[BEG_CNTY_LOGMILE2]","VB","#")
CalculateField_management(operws+"LRM_CR_PART","END_CNTY_LOGMILE","[END_CNTY_LOGMILE2]","VB","#")
TransformRouteEvents_lr(operws+"LRM_CR_PART","LRS_KEY LINE BEG_CNTY_LOGMILE2 END_CNTY_LOGMILE2",operws+"CMLRS","LRS_KEY",operws+"SMLRS","LRS_ROUTE",operws+"LRM_SR_PART","LRS_ROUTE LINE BEG_STATE_LOGMILE2 END_STATE_LOGMILE2","0 DecimalDegrees","FIELDS")
CalculateField_management(operws+"LRM_SR_PART","BEG_STATE_LOGMILE","[BEG_STATE_LOGMILE2]","VB","#")
CalculateField_management(operws+"LRM_SR_PART","END_STATE_LOGMILE","[END_STATE_LOGMILE2]","VB","#")
MakeRouteEventLayer_lr(operws+"SMLRS","LRS_ROUTE",operws+"LRM_SR_PART","LRS_ROUTE LINE BEG_STATE_LOGMILE END_STATE_LOGMILE","STATE_SYSTEM_PRECISION_SDO","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
FeatureClassToFeatureClass_conversion("STATE_SYSTEM_PRECISION_SDO", ws+"\\"+tempgdb,"STATE_SYSTEM_PRECISION") #23 sec
print "completed Precision Network for SDO"
        
Esempio n. 15
0
def StateHighwayCalibrate(theStateHighwaySegments):
    #theStateHighwaySegments is defined as the roadway segments intended for calibration to the EXOR measures
    #this function is being called by

    #here are the GIS routes with measures extracted regularly from EXOR using the FME extraction and python route reference tools from DT00ar60
    #these routes contain the current exor measures
    #Smlrs = r'Database Connections\RO@sqlgisprod_GIS_cansys.sde\GIS_CANSYS.SHARED.SMLRS'

    #need to define a route source represntative of the correct network year, about 2015
    #should have K-10 on 23rd street still

    Cmlrs = r'Database Connections\RO@sqlgisprod_GIS_cansys.sde\GIS_CANSYS.SHARED.CMLRS_2015'

    from arcpy import FeatureClassToFeatureClass_conversion, FeatureVerticesToPoints_management, LocateFeaturesAlongRoutes_lr, CalculateField_management
    from arcpy import env, MakeFeatureLayer_management, SelectLayerByAttribute_management, DeleteRows_management, AddJoin_management, AddField_management, RemoveJoin_management
    env.overwriteOutput = 1
    # Start by loading NG911 aggregated, conflated road centerlines to an in-memory feature class

    #FeatureClassToFeatureClass_conversion(Roads, "in_memory", "RoadCenterlines", "StateKey1 IS NOT NULL ")
    #FeatureClassToFeatureClass_conversion(Roads, "in_memory", "RoadCenterlines", "StateKey1 IS NOT NULL ")

    MakeFeatureLayer_management(theStateHighwaySegments,
                                "CalibrateRoadCenterlines")
    RoadCenterlines = "CalibrateRoadCenterlines"
    #these are the two linear referencing networks we're going to use to calibrate the state highway system
    #for iteration 2, no source data should refer to the state LRM, so we're only doing the County LRM
    Lrm_Dict = {'COUNTY': Cmlrs}

    #and this is the beginning and end of a line, for which we are going to create a vertex point
    End_List = ['START', 'END']

    # First,  create points at the begin and end of each road centerline segment using Vertices to Points.
    for end in End_List:
        i_end_output = "in_memory/CalibrationPoint" + str(end)
        FeatureVerticesToPoints_management(RoadCenterlines, i_end_output,
                                           str(end))

    #Iterate through the LRMs to bring them into memory and do the processing for each segment begin and end point!
    for key, value in Lrm_Dict.items():
        FeatureClassToFeatureClass_conversion(value, "in_memory",
                                              "LRM" + str(key))
        for end in End_List:
            outtable = "in_memory/" + str(end) + "_" + str(key)
            outstore = spampathfd + r"/" + str(end) + "_" + str(key)
            outproperties = str(key) + "_LRS POINT MEAS_" + str(key)
            if key == "STATE":
                lrskey = str(key) + "_NQR_DESCRIPTION"
            else:
                lrskey = "NQR_DESCRIPTION"
            LocateFeaturesAlongRoutes_lr(
                "in_memory/CalibrationPoint" + str(end),
                "in_memory/LRM" + str(key), lrskey, "500 Feet", outtable,
                outproperties, "ALL", "DISTANCE", "ZERO", "FIELDS",
                "M_DIRECTON")

            #that LFAR function located begin/end segment points to ALL ROUTES within 500 feet of the segment endpoint

            #for calibrating, we are only interested in the points and LFAR Results that where this query is NOT true:
            qNotThisRoad = '"COUNTY_LRS" <> "KDOT_LRS_KEY"'
            #so we will delete the records where this query is trye
            SelectLayerByAttribute_management(
                str(end) + "_" + str(key), "NEW_SELECTION", qNotThisRoad)
            DeleteRows_management(str(end) + "_" + str(key))
            #DeleteField_management(outtable, "Mileage_Length;Mileage_Logmile;ROUTE_PREFIX_TARGET;LRS_ROUTE_NUM_TARGET;LRS_UNIQUE_TARGET;Non_State_System_OBJECTID;LRS_BACKWARD;F_CNTY_2;T_CNTY_2;F_STAT_2;T_STAT_2;CountyKey2;MileFlipCheck;InLine_FID;SimLnFLag")

            #TableToTable_conversion(outtable, ConflationDatabase, outstore)
            #One Method, if using SQL Server, is to use table to table conversion to export to SQL server, then run these query in #CalcUsingSQLserver()
            #If not using SQL server this will suffice, although if there are multiple orig FID's to the original data source FID, there's no logic or handling to discern between the many to one relationship.
            #In the case of hte many to one, or duplicate Orig_FID in the measure table, it might be desirable to choose the closest result
            #A few of the duplicates I reviewed had identical measure values, if that's always the case, then handling the duplicates is unnecessary
            measfield = str(end) + "_" + str(key) + "_meas"
            try:
                AddField_management(theStateHighwaySegments, measfield,
                                    "DOUBLE", "", "", "", "", "NULLABLE",
                                    "NON_REQUIRED")
            except:
                print "could not add the field for calibrated measures"
            jointable = str(end) + "_" + str(key)
            AddJoin_management(theStateHighwaySegments, "OBJECTID", jointable,
                               "ORIG_FID", "KEEP_ALL")
            exp = "!" + jointable + ".MEAS_" + str(key) + "!"
            measfieldcalc = theStateHighwaySegments + "." + measfield
            CalculateField_management(theStateHighwaySegments, measfieldcalc,
                                      exp, "PYTHON")
            RemoveJoin_management(theStateHighwaySegments)

        # NEed to now test for direction again based on begin < end, handle flipping and assemble the routes
    from arcpy import CreateRoutes_lr
    CreateRoutes_lr("CalibrateRoadCenterlines", "KDOT_LRS_KEY",
                    "in_memory/Simplified_CreateRoutes_test1", "TWO_FIELDS",
                    "START_COUNTY_meas", "END_COUNTY_meas", "UPPER_LEFT", "1",
                    "0", "IGNORE", "INDEX")
def RM_Calibrate():
    import datetime
    startDateTime = datetime.datetime.now()
    print(
        "starting SHS calibration at " + str(startDateTime) +
        ", it should take about 20 minutes to calibrate non-state system urban and rural classified routes"
    )

    from KhubCode25.KhubCode25Config import devorprod, dbname, dbownername, localProFileGDBWorkspace, KDOTConnections, prodDataSourceSDE, devDataSourceSDE, RuralClassifiedRoutes, UrbanClassifiedRoutes

    if devorprod == 'prod':
        database = prodDataSourceSDE

        print("running on " + devorprod)
    else:
        database = devDataSourceSDE

        print("running on " + devorprod)
    fileformatDateStr = startDateTime.strftime("%Y%m%d")
    from arcpy import (MakeFeatureLayer_management,
                       FeatureVerticesToPoints_management,
                       LocateFeaturesAlongRoutes_lr, MakeRouteEventLayer_lr,
                       Dissolve_management, Exists)

    localfilegdb = localProFileGDBWorkspace + '\\' + 'KhubRoadCenterlinesTemp' + fileformatDateStr + '.gdb'
    print(localfilegdb)
    sdegdb = KDOTConnections + r'\\' + database + r'\\' + dbname + "." + dbownername
    CalibrateD1 = sdegdb + ".All_Road_Centerlines_D1"
    RMRoute = sdegdb + "." + RuralClassifiedRoutes
    Croutes = sdegdb + "." + UrbanClassifiedRoutes
    FeatureClassToFeatureClass(RMRoute, localfilegdb, "RM_Routes")
    nusysprimary = "DIRECTION IN ('EB', 'NB') Or (DIVIDED_UNDIVIDED = 'U' And DIRECTION IN ('SB', 'WB'))"
    FeatureClassToFeatureClass(Croutes, localfilegdb, "C_Routes", nusysprimary)

    RMRoute = localfilegdb + "." + r"/RM_Routes"
    Croutes = localfilegdb + "." + r"/C_Routes"

    MakeFeatureLayer_management(CalibrateD1, "D1_NUSYS",
                                "LRS_ROUTE_PREFIX = 'C'", None, "#")
    MakeFeatureLayer_management(CalibrateD1, "D1_RM",
                                "LRS_ROUTE_PREFIX IN ('M', 'R')", None, "")

    print("making endpoints for nusys")
    FeatureVerticesToPoints_management("D1_NUSYS",
                                       localfilegdb + r"\Nusys_END", "END")
    FeatureVerticesToPoints_management("D1_NUSYS",
                                       localfilegdb + r"\Nusys_START", "START")
    print("making endpoints for rural")
    FeatureVerticesToPoints_management("D1_RM", localfilegdb + r"\RM_END",
                                       "END")
    FeatureVerticesToPoints_management("D1_RM", localfilegdb + r"\RM_START",
                                       "START")

    print("Exporting rural event tables")
    LocateFeaturesAlongRoutes_lr(localfilegdb + r"\RM_START", RMRoute,
                                 "LRS_KEY", "250 Feet",
                                 localfilegdb + r"\START_D1_RM",
                                 "LRS_KEY Point RM_MEAS", "ALL", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")
    LocateFeaturesAlongRoutes_lr(localfilegdb + r"\RM_END", RMRoute, "LRS_KEY",
                                 "250 Feet", localfilegdb + r"\END_D1_RM",
                                 "LRS_KEY Point RM_MEAS", "ALL", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")
    print("Exporting urban event tables")

    print("starting start c")

    LocateFeaturesAlongRoutes_lr(localfilegdb + r"\Nusys_START", Croutes,
                                 "Route", "250 Feet",
                                 localfilegdb + r"\START_D1_C",
                                 "LRS_KEY Point C_MEAS", "ALL", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")
    print("starting end c")
    LocateFeaturesAlongRoutes_lr(localfilegdb + r"\Nusys_END", Croutes,
                                 "Route", "250 Feet",
                                 localfilegdb + r"\END_D1_C",
                                 "LRS_KEY Point C_MEAS", "ALL", "DISTANCE",
                                 "ZERO", "FIELDS", "M_DIRECTON")

    MakeRouteEventLayer_lr(RMRoute, "LRS_KEY", localfilegdb + r"\START_D1_RM",
                           "LRS_KEY Point RM_MEAS", "START_D1_RM Events", None,
                           "ERROR_FIELD", "ANGLE_FIELD", "NORMAL",
                           "COMPLEMENT", "LEFT", "POINT")
    MakeRouteEventLayer_lr(RMRoute, "LRS_KEY", localfilegdb + r"\END_D1_RM",
                           "LRS_KEY Point RM_MEAS", "END_D1_RM Events", None,
                           "ERROR_FIELD", "ANGLE_FIELD", "NORMAL",
                           "COMPLEMENT", "LEFT", "POINT")

    MakeRouteEventLayer_lr(Croutes, "Route", localfilegdb + r"\START_D1_C",
                           "LRS_KEY Point C_MEAS", "START_D1_C Events", None,
                           "ERROR_FIELD", "ANGLE_FIELD", "NORMAL",
                           "COMPLEMENT", "LEFT", "POINT")
    MakeRouteEventLayer_lr(Croutes, "Route", localfilegdb + r"\END_D1_C",
                           "LRS_KEY Point C_MEAS", "END_D1_C Events", None,
                           "ERROR_FIELD", "ANGLE_FIELD", "NORMAL",
                           "COMPLEMENT", "LEFT", "POINT")

    Dissolve_management(
        "START_D1_RM Events", localfilegdb + r"\START_D1_RM_DX",
        "LRS_KEY;RM_MEAS;KDOT_LRS_KEY",
        "Distance MIN;Distance MAX;KDOT_STATIC_ID2 FIRST;OBJECTID COUNT;RM_MEAS MIN;RM_MEAS MAX",
        "MULTI_PART", "DISSOLVE_LINES")
    FeatureClassToFeatureClass(localfilegdb + r"\START_D1_RM_DX", localfilegdb,
                               "START_D1_RM_D", "KDOT_LRS_KEY = LRS_KEY", "#")
    print("START_D1_RM_D")

    Dissolve_management(
        "END_D1_RM Events", localfilegdb + r"\END_D1_RM_DX",
        "LRS_KEY;RM_MEAS;KDOT_LRS_KEY",
        "Distance MIN;Distance MAX;KDOT_STATIC_ID2 FIRST;OBJECTID COUNT;RM_MEAS MIN;RM_MEAS MAX",
        "MULTI_PART", "DISSOLVE_LINES")
    FeatureClassToFeatureClass(localfilegdb + r"\END_D1_RM_DX", localfilegdb,
                               "END_D1_RM_D", "KDOT_LRS_KEY = LRS_KEY", "#")
    print("END_D1_RM_D")

    Dissolve_management(
        "START_D1_C Events", localfilegdb + r"\START_D1_C_DX",
        "LRS_KEY;C_MEAS;KDOT_LRS_KEY",
        "Distance MIN;Distance MAX;KDOT_STATIC_ID2 FIRST;OBJECTID COUNT;C_MEAS MIN;C_MEAS MAX",
        "MULTI_PART", "DISSOLVE_LINES")
    FeatureClassToFeatureClass(
        localfilegdb + r"\START_D1_C_DX", localfilegdb, "START_D1_C_D",
        "SUBSTRING(KDOT_LRS_KEY,0, 9) = SUBSTRING(LRS_KEY,0,9)", "#")
    print("START_D1_C_D")

    Dissolve_management(
        "END_D1_C Events", localfilegdb + r"\END_D1_C_DX",
        "LRS_KEY;C_MEAS;KDOT_LRS_KEY",
        "Distance MIN;Distance MAX;KDOT_STATIC_ID2 FIRST;OBJECTID COUNT;C_MEAS MIN;C_MEAS MAX",
        "MULTI_PART", "DISSOLVE_LINES")
    FeatureClassToFeatureClass(
        localfilegdb + r"\END_D1_C_DX", localfilegdb, "END_D1_C_D",
        "SUBSTRING(KDOT_LRS_KEY,0, 9) = SUBSTRING(LRS_KEY,0,9)", "#")
    print("END_D1_C_D")

    print(
        'Calibration process completed in {} hours, minutes, seconds.'.format(
            datetime.datetime.now() - startDateTime))
Esempio n. 17
0
def LinearReferenceCheck():
    print "locating NON_STATE_SYSTEM features along the NUSYS Rotue - creates an event table with Route/begin/end mileage"
    print "the tolerance for this process is 20 feet.  Because this is not an exact process, it is for reference purposes only to compare segmentation mileage"
    print "it looks like unless calculated segment per segment, this will not ever be exact"
    LocateFeaturesAlongRoutes_lr(NonState_fx, NUSYS, "ROUTE", "20 Feet", "Nonstate_Nusys_LFAR", "RID LINE FMEAS TMEAS", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
    MakeRouteEventLayer_lr(in_routes="Nusys_Extract", route_id_field="route", in_table="Nonstate_Nusys_LFAR", in_event_properties="rid LINE fmeas tmeas", out_layer="Nonstate_Nusys_LFAR Events", offset_field="", add_error_field="ERROR_FIELD", add_angle_field="NO_ANGLE_FIELD", angle_type="NORMAL", complement_angle="ANGLE", offset_direction="LEFT", point_event_type="POINT")
Esempio n. 18
0
env.MTolerance = 0.0002

rsel = "ENDDATE IS NULL"
MakeTableView_management(resolve, "CCL_Resolution_tbl", rsel)
CalculateField_management("CCL_Resolution_tbl", "CCL_LRS",
                          'str(!CITYNUMBER!)+str(!LRS_KEY![3:14])', "PYTHON")
MakeTableView_management(connection1 + "CCL_Resolution",
                         "CCL_Resolution_tbl10", 'CITYNUMBER<100')
CalculateField_management("CCL_Resolution_tbl10", "CCL_LRS",
                          '"0"+str(!CITYNUMBER!)+str(!LRS_KEY![3:14])',
                          "PYTHON")
MakeFeatureLayer_management(citylimits, "CityLimits", "TYPE IN ( 'CS', 'ON')")
MakeFeatureLayer_management(cntyroutelyr, "clrs")
MakeFeatureLayer_management(stateroutelyr, "smlrs")
LocateFeaturesAlongRoutes_lr(citylimits, "clrs", "LRS_KEY", "60 Feet",
                             connection1 + "GIS_CITY",
                             "LRS_KEY LINE Beg_CMP End_CMP", "FIRST",
                             "DISTANCE", "NO_ZERO", "FIELDS", "M_DIRECTON")
MakeRouteEventLayer_lr("clrs", "LRS_KEY", "CCL_Resolution_tbl",
                       "LRS_KEY LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE",
                       "City_Connecting_Links", "#", "ERROR_FIELD",
                       "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
MakeTableView_management(connection1 + "GIS_CITY", "GIS_CITY")
MakeRouteEventLayer_lr("clrs", "LRS_KEY", "GIS_CITY",
                       "LRS_KEY LINE BEG_CMP END_CMP", "GIS_BASED_CCL", "#",
                       "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE",
                       "LEFT", "POINT")
OverlayRouteEvents_lr(connection1 + "CCL_Resolution",
                      "LRS_KEY LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE",
                      laneclass,
                      "LRS_KEY LINE Beg_Cnty_Logmile End_Cnty_Logmile",
                      "UNION", connection1 + "CCL_LANE_CLASS_OVERLAY",
Esempio n. 19
0
#Remove the CANP Prod layers
for df in mapping.ListDataFrames(mxd):
    for lyr in mapping.ListLayers(mxd, "", df):
        mapping.RemoveLayer(df, lyr)
RefreshActiveView()

#Start the processing to rebuild layers
MakeFeatureLayer_management(STAGEDB+r"\SRND", "SRND")
SRNDelem = "NE_NT_TYPE = 'SRND' AND NE_VERSION_NO in ('EB', 'NB')"
MakeTableView_management(STAGEDB+r"\ELEMENTS_ALL", "SRND_ELEM", SRNDelem)
AddJoin_management("SRND", "NE_ID", "SRND_ELEM", "NE_ID", "KEEP_COMMON")

#Create the vertices for calibration points
FeatureVerticesToPoints_management("SRND", STAGEDB+"/Calibration_Points_SRND","ALL")
AddXY_management("GIS_CANSYS.DBO.Calibration_Points_SRND")
'''
LocateFeaturesAlongRoutes_lr(ws+"\\"+tempgdb+"/Calibration_Points",ws+"\\"+tempgdb+"/SRND","NE_UNIQUE","0.001 Feet",ws+"\\"+tempgdb+"/CP_SRND","STATE_MILE POINT SR_MEAS","ALL","DISTANCE","ZERO","FIELDS","M_DIRECTON")
AddJoin_management("SECT","RSE_HE_ID","Elements","NE_ID","KEEP_COMMON")

FeatureClassToFeatureClass_conversion("SECT",STAGEDB,"CANSYS_SECTIONS", "#", "#"  )

pathloc = ws+"\\"+tempgdb
routelyr = ws+"\\"+tempgdb+"\\"+route
inlyr2 = ws+"\\"+tempgdb+"/STATE_SYSTEM"

inlyr1 = ws+"\\"+tempgdb+"/Calibration_Points"
'''



Esempio n. 20
0
                                       i_end_output, str(end))

#Iterate through the LRMs to bring them into memory and do the processing for each segment begin and end point!
for key, value in Lrm_Dict.items():
    FeatureClassToFeatureClass_conversion(value, "in_memory", "LRM" + str(key))
    for end in End_List:
        outtable = "in_memory/" + str(end) + "_" + str(key)
        outstore = ConflationDatabase + r"/" + str(end) + "_" + str(key)
        outproperties = str(key) + "_LRS POINT MEAS_" + str(key)
        if key == "STATE":
            lrskey = str(key) + "_NQR_DESCRIPTION"
        else:
            lrskey = "NQR_DESCRIPTION"
        LocateFeaturesAlongRoutes_lr("in_memory/CalibrationPoint" + str(end),
                                     "in_memory/LRM" + str(key), lrskey,
                                     "500 Feet", outtable, outproperties,
                                     "ALL", "DISTANCE", "ZERO", "FIELDS",
                                     "M_DIRECTON")

        #there is a bug here between hte LFAR, DeleteField_management, TableToTable_conversion code
        #delete field - the tables are corrupt in memory upon running deletefield management
        #note bug ##### cannot delete ST_SHAPE LENGTH FIELD IN ANY GEODATABASE INLUDING IN MEMORY GEODATABASE
        DeleteField_management(
            outtable,
            "STEWARD;L_UPDATE;EFF_DATE;EXP_DATE;SEGID;STATE_L;STATE_R;COUNTY_L;COUNTY_R;MUNI_L;MUNI_R;L_F_ADD;L_T_ADD;R_F_ADD;R_T_ADD;PARITY_L;PARITY_R;POSTCO_L;POSTCO_R;ZIP_L;ZIP_R;ESN_L;ESN_R;MSAGCO_L;MSAGCO_R;PRD;STP;RD;STS;POD;POM;SPDLIMIT;ONEWAY;RDCLASS;UPDATEBY;LABEL;ELEV_F;ELEV_T;ESN_C;SURFACE;STATUS;TRAVEL;LRSKEY;UNINC_L;UNINC_R;EXCEPTION_;SUBMIT;NOTES;COUNTY_BEGIN_MP;COUNTY_END_MP;STATE_BEGIN_MP;STATE_END_MP;NON_STATE_BEGIN_MP;NON_STATE_END_MP;STATE_FLIP_FLAG;STATE_MILEAGE_FLAG;NON_STATE_FLIP_FLAG;NON_STATE_MILEAGE_FLAG;State_System_LRSKey;Non_State_System_LRSKey;Ramps_LRSKey;BEG_NODE;END_NODE;Con_Surface;KDOT_BEG_LOGMILE;KDOT_END_LOGMILE;KDOT_LRS_KEY;KDOT_DIRECTION_CALC;RID;FMEAS;TMEAS;LRS_COUNTY_PRE;LRS_URBAN_PRE;LRS_ROUTE_PREFIX;LRS_ROUTE_SUFFIX;LRS_UNIQUE_IDENT;LRS_ADMO;LRS_SUBCLASS;LRS_DIRECTION;MILEAGE_COUNTED;LRS_ROUTE_NUM;KDOT_QA;RouteID;FromDate;ToDate;LRS_ROUTE_NUM1;LRS_UNIQUE_IDENT1;LRS_PRIMARY_DIR;LRS_RdNm_Soundex;RouteID2;KDOT_RAMP_CRASH_ID;KDOT_COUNTY_L;KDOT_COUNTY_R;KDOT_MUNI_L;KDOT_MUNI_R;created_user;created_date;last_edited_user;last_edited_date;CountyKey1;StateKey1;F_CNTY_1;T_CNTY_1;F_STAT_1;T_STAT_1;ORIG_FID"
        )
        #tableto table conversion from in memory to SQL server throws unhandled error
        #TableToTable_conversion(outtable, ConflationDatabase, outstore)

print "Done!!!"
# At this point, all the values we need to calculate the calibrated begin/end mileage of a segment are stored in SQL server
Esempio n. 21
0
def SecondaryDirectionFinder():
    #make a point at the center of each line segment for a highway
    #No way currently to do this for RML highways,  NUSYS provides the directional layer for C highwyas
    #FeatureToPoint_management("State Highways", "in_memory/HighwayPoints", "INSIDE")
    #maybe two ways to do this, this time, I'm using midpoint from feature to point - catch
    FeatureVerticesToPoints_management(
        "RoadCenterlines",
        out_feature_class="in_memory/HighwayPoints",
        point_location="MID")
    #FeatureToPoint_management(Roads, "in_memory/HighwayPoints", "INSIDE")
    FeatureClassToFeatureClass_conversion(
        SRND,
        "in_memory",
        "SRND_NPD",
        where_clause="NETWORK_DIRECTION IN ( 'SB' , 'WB' )")

    #CRND Secondary Direction is the CRND layer where "NETWORK_DIRECTION IN ( 'SB' , 'WB' )"
    #Locate Features Along Routes will calculate a +/- offset distance of the dual carriageway points from the CRND centerline
    LocateFeaturesAlongRoutes_lr("HighwayPoints", "SRND_NPD", "NE_UNIQUE",
                                 "500 Feet", "in_memory/HighwayPointsMeasures",
                                 "RID POINT MEAS", "ALL", "DISTANCE", "ZERO",
                                 "FIELDS", "M_DIRECTON")

    #All the Highway Points are no longer needed and can be freed from memory
    Delete_management("HighwayPoints")

    #since we located along all routes instead of the nearest routes, we need to select the rows that have the correct LRS key
    #SelectLayerByAttribute_management("in_memory/HighwayPointsMeasures", "NEW_SELECTION", """SUBSTRING( "RID", 1, 7) NOT  LIKE SUBSTRING("StateKey1", 4, 7)""")

    #Using State_System_LRSKey from Conflation just in case the StateKey1 has not yet been added or calculated.
    SelectLayerByAttribute_management(
        "HighwayPointsMeasures", "NEW_SELECTION",
        """SUBSTRING( "RID", 1, 7) NOT  LIKE SUBSTRING("State_System_LRSKey" ,4, 7)"""
    )
    DeleteRows_management(in_rows="HighwayPointsMeasures")
    # point events are located along the routes that KDOT says are divided on the dual carriageway
    MakeRouteEventLayer_lr("SRND_NPD",
                           "NE_UNIQUE",
                           "HighwayPointsMeasures",
                           "rid POINT MEAS",
                           "HighwayPointEvents",
                           offset_field="Distance",
                           add_error_field="ERROR_FIELD",
                           add_angle_field="ANGLE_FIELD",
                           angle_type="NORMAL",
                           complement_angle="ANGLE",
                           offset_direction="RIGHT",
                           point_event_type="POINT")

    #select the secondary direction points based on the offset direction
    MakeFeatureLayer_management("HighwayPointEvents", "NPD_ID",
                                """"Distance">=0""")

    # some random points, due to the 500 ft buffer I think, are getting included.  Select the event points that do not intersect a state highway road centerline feature
    #
    SelectLayerByLocation_management("NPD_ID", "INTERSECT", "RoadCenterlines",
                                     "1 Feet", "NEW_SELECTION")

    #sometimes (center turn lanes, left turn lanes, painted medians, median terminus locations)
    #there is a difference between what KDOT says is Divided and the dual carriagway geometry.
    #Consider this and determine how to handle divided highways in the route Keys/route structures.
    #this next step will only factor in the

    FeatureClassToFeatureClass_conversion(
        "NPD_ID",
        ConflationDatabase + "\\" + GeodatabaseName + ".SDE.KANSAS_DOT",
        "Non_Primary_Divided_Highway", '"Distance">=0')
Esempio n. 22
0
    lyr = lyr + "_C"
    IDField = ListFields(lyr, "*NE_ID*", "Integer")
    for field in IDField:
        PKfield = "{}".format(field.name)
        AddJoin_management(lyr, PKfield, "Members", "NM_NE_ID_IN",
                           "KEEP_COMMON")
        AddJoin_management(lyr, "NM_NE_ID_OF", "Elements", "NE_ID",
                           "KEEP_COMMON")
        print str(lyr) + " elements table joined"

for lyr in linelyrlist:
    print lyr + "_C is the layer I'm linear referencing now..."
    outlyr = ws + "\\" + tempgdb + "\\" + str(lyr) + "_ln_1"
    lyr = lyr + "_C"
    LocateFeaturesAlongRoutes_lr(
        lyr, "CMLRS", "LRS_KEY", '0.5 feet', outlyr,
        "LRS_KEY LINE Beg_Cnty_Logmile End_Cnty_Logmile", "FIRST", "DISTANCE",
        "NO_ZERO", "FIELDS", "NO_M_DIRECTION")
    MakeRouteEventLayer_lr("CMLRS", "LRS_KEY", outlyr,
                           "LRS_KEY LINE Beg_Cnty_Logmile End_Cnty_Logmile",
                           lyr + "_Events", "#", "ERROR_FIELD",
                           "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT",
                           "POINT")
    print str(lyr) + " event table located as lines " + str(outlyr)
    del lyr

wsouttbl = ws + "\\" + tempgdb

lyrlist = ["AADT"]

itemname = 'AADT'
cantbl = itemname + "_ln_1"
def StateHighwayCalibrate():
    import datetime
    startDateTime = datetime.datetime.now()
    print("starting SHS calibration at " + str(startDateTime) +
          ", it should take about 15 minutes to calibrate state system routes")
    #Calibration process completed in 0:03:36.252839 hours, minutes, seconds
    from KhubCode25.KhubCode25Config import devorprod, dbname, dbownername, localProFileGDBWorkspace, KDOTConnections, Cmlrs, prodDataSourceSDE, devDataSourceSDE
    fileformatDateStr = startDateTime.strftime("%Y%m%d")
    #theStateHighwaySegments is defined as the roadway segments intended for calibration to the EXOR measures
    if devorprod == 'prod':
        database = prodDataSourceSDE

        print("running on " + devorprod)
    else:
        database = devDataSourceSDE

        print("running on " + devorprod)
    from arcpy import FeatureClassToFeatureClass_conversion, Delete_management, FeatureVerticesToPoints_management, LocateFeaturesAlongRoutes_lr, CreateFileGDB_management, env, MakeFeatureLayer_management, SelectLayerByAttribute_management, DeleteRows_management, MakeTableView_management
    env.overwriteOutput = 1
    try:
        CreateFileGDB_management(localProFileGDBWorkspace,
                                 "KhubRoadCenterlinesTemp" + fileformatDateStr,
                                 "CURRENT")
    except:
        Delete_management(localProFileGDBWorkspace,
                          "KhubRoadCenterlinesTemp" + fileformatDateStr)
        CreateFileGDB_management(localProFileGDBWorkspace,
                                 "KhubRoadCenterlinesTemp" + fileformatDateStr,
                                 "CURRENT")

    #stopped using in_memory after the upgrade to arcgis pro, it doesn't work like it used to do.
    #consider using in memory for not in non-pro script environment, but for this process, probably will not make much difference

    localfilegdb = localProFileGDBWorkspace + '\\' + 'KhubRoadCenterlinesTemp' + fileformatDateStr + '.gdb'
    sdegdb = KDOTConnections + r'\\' + database + r'\\' + dbname + "." + dbownername
    firstCut = sdegdb + ".All_Road_Centerlines"
    NextIter = "_D1"
    nextCut = firstCut + NextIter
    RoadsToCalibrate = [firstCut, nextCut]

    CMLRS = sdegdb + "." + Cmlrs
    Lrm_Dict = {'COUNTY': CMLRS}
    for sderoads in RoadsToCalibrate:
        if sderoads[-3:] == "_D1":
            MakeFeatureLayer_management(
                sderoads, "lyrStateSystemSource" + NextIter,
                "LRS_ROUTE_PREFIX IN ('I', 'U', 'K') And LRS_ROUTE_SUFFIX NOT IN ('Z', 'G')",
                None, "")
            RoadCenterlines = localfilegdb + "/lyrStateSystemSource" + NextIter
            End_List = ['START', 'END']
            # First,  create points at the begin and end of each road centerline segment using Vertices to Points.
            for end in End_List:
                end_name = end + NextIter
                i_end_output = localfilegdb + "/CalibrationPoint" + end_name
                try:
                    FeatureVerticesToPoints_management(RoadCenterlines,
                                                       i_end_output, str(end))
                    #this works in Pro
                except:
                    FeatureVerticesToPoints_management(
                        "lyrStateSystemSource" + NextIter, i_end_output,
                        str(end))
        #and this is the beginning and end of a line, for which we are going to create a vertex point
        #Iterate through the LRMs to bring them into memory and do the processing for each segment begin and end point!
                for key, value in Lrm_Dict.items():
                    FeatureClassToFeatureClass_conversion(
                        value, localfilegdb, "LRM" + str(key))
                    for end in End_List:
                        outtable = localfilegdb + r"/" + str(
                            end_name) + "_" + str(key)
                        outproperties = str(key) + "_LRS POINT MEAS_" + str(
                            key)
                        if key == "STATE":
                            lrskey = str(key) + "_NQR_DESCRIPTION"
                        else:
                            lrskey = "NQR_DESCRIPTION"
                        try:
                            LocateFeaturesAlongRoutes_lr(
                                localfilegdb + r"/CalibrationPoint" +
                                str(end_name), "LRM" + str(key), lrskey,
                                "500 Feet", outtable, outproperties, "ALL",
                                "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
                            #this works in Pro
                        except:
                            LocateFeaturesAlongRoutes_lr(
                                localfilegdb + "/CalibrationPoint" +
                                str(end_name),
                                localfilegdb + r"/LRM" + str(key), lrskey,
                                "500 Feet", outtable, outproperties, "ALL",
                                "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
                            #this works in non-Pro script environment

                        #that LFAR function located begin/end segment points to ALL ROUTES within 500 feet of the segment endpoint

                        #for calibrating, we are only interested in the points and LFAR Results that where this query is NOT true:
                        qNotThisRoad = 'SUBSTRING("COUNTY_LRS",0,10) <> SUBSTRING("KDOT_LRS_KEY",0,10)'
                        #so we will delete the records where this query is trye
                        try:
                            SelectLayerByAttribute_management(
                                str(end_name) + "_" + str(key),
                                "NEW_SELECTION", qNotThisRoad)
                            DeleteRows_management(
                                str(end_name) + "_" + str(key))
                            #this works in Pro Environment
                        except:
                            #SelectLayerByAttribute_management(localfilegdb+"/"+str(end)+"_"+str(key), "NEW_SELECTION", qNotThisRoad)
                            MakeTableView_management(
                                localfilegdb + "/" + str(end_name) + "_" +
                                str(key), "deleterows", qNotThisRoad, None, "")
                            DeleteRows_management("deleterows")
                            #this works in non-Pro script environment
                #this works in non-Pro script environment
        else:
            MakeFeatureLayer_management(
                sderoads, "lyrStateSystemSource",
                "LRS_ROUTE_PREFIX IN ('I', 'U', 'K') And LRS_ROUTE_SUFFIX NOT IN ('Z', 'G')",
                None, "")
            RoadCenterlines = localfilegdb + "/lyrStateSystemSource"
            End_List = ['START', 'END']
            for end in End_List:
                end_name = end
                print(end_name)
                i_end_output = localfilegdb + "/CalibrationPoint" + str(end)
                try:
                    FeatureVerticesToPoints_management(RoadCenterlines,
                                                       i_end_output, str(end))
                    #this works in Pro
                except:
                    FeatureVerticesToPoints_management("lyrStateSystemSource",
                                                       i_end_output, str(end))
        #and this is the beginning and end of a line, for which we are going to create a vertex point
        #Iterate through the LRMs to bring them into memory and do the processing for each segment begin and end point!
                for key, value in Lrm_Dict.items():
                    FeatureClassToFeatureClass_conversion(
                        value, localfilegdb, "LRM" + str(key))
                    for end in End_List:
                        outtable = localfilegdb + r"/" + str(
                            end_name) + "_" + str(key)
                        outproperties = str(key) + "_LRS POINT MEAS_" + str(
                            key)
                        if key == "STATE":
                            lrskey = str(key) + "_NQR_DESCRIPTION"
                        else:
                            lrskey = "NQR_DESCRIPTION"
                        try:
                            LocateFeaturesAlongRoutes_lr(
                                localfilegdb + r"/CalibrationPoint" +
                                str(end_name), "LRM" + str(key), lrskey,
                                "500 Feet", outtable, outproperties, "ALL",
                                "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
                            #this works in Pro
                        except:
                            LocateFeaturesAlongRoutes_lr(
                                localfilegdb + "/CalibrationPoint" +
                                str(end_name),
                                localfilegdb + r"/LRM" + str(key), lrskey,
                                "500 Feet", outtable, outproperties, "ALL",
                                "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
                            #this works in non-Pro script environment

                        #that LFAR function located begin/end segment points to ALL ROUTES within 500 feet of the segment endpoint

                        #for calibrating, we are only interested in the points and LFAR Results that where this query is NOT true:
                        qNotThisRoad = 'SUBSTRING("COUNTY_LRS",0,10) <> SUBSTRING("KDOT_LRS_KEY",0,10)'
                        #so we will delete the records where this query is true
                        #It is possible that there will be multiple rows where this query is true, this result
                        #will calculate one value, not conditional on distance, min/max, just takes the first true result I guess
                        #in situations where there are multiple results, consider dissolving these points and keeping some stats
                        #then review stats to determine appropriate value, probably the closest result
                        try:
                            SelectLayerByAttribute_management(
                                str(end_name) + "_" + str(key),
                                "NEW_SELECTION", qNotThisRoad)
                            DeleteRows_management(
                                str(end_name) + "_" + str(key))
                            #this works in Pro Environment
                        except:
                            #SelectLayerByAttribute_management(localfilegdb+"/"+str(end)+"_"+str(key), "NEW_SELECTION", qNotThisRoad)
                            MakeTableView_management(
                                localfilegdb + "/" + str(end_name) + "_" +
                                str(key), "deleterows", qNotThisRoad, None, "")
                            DeleteRows_management("deleterows")
                            #this works in non-Pro script environment
    print(
        'Calibration process completed in {} hours, minutes, seconds.'.format(
            datetime.datetime.now() - startDateTime))
Esempio n. 24
0
def SecondaryDirectionFinder():
    #make a point at the center of each line segment for a highway
    #No way currently to do this for RML highways,  NUSYS provides the directional layer for C highwyas
    #FeatureToPoint_management("State Highways", "in_memory/HighwayPoints", "INSIDE")
    #maybe two ways to do this, this time, I'm using midpoint from feature to point - catch
    FeatureVerticesToPoints_management(
        in_features="RoadCenterlines",
        out_feature_class="in_memory/HighwayPoints",
        point_location="MID")

    FeatureClassToFeatureClass_conversion(
        SRND,
        "in_memory",
        "SRND_NPD",
        where_clause="NETWORK_DIRECTION IN ( 'SB' , 'WB' )")

    #CRND SEcondary Direction is the CRND layer where "NETWORK_DIRECTION IN ( 'SB' , 'WB' )"
    #Locate Features Along Routes will calculate a +/- offset distance of the dual carriageway points from the CRND centerline
    LocateFeaturesAlongRoutes_lr("HighwayPoints", "SRND_NPD", "NE_UNIQUE",
                                 "500 Feet", "in_memory/HighwayPointsMeasures",
                                 "RID POINT MEAS", "ALL", "DISTANCE", "ZERO",
                                 "FIELDS", "M_DIRECTON")
    # Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
    # The following inputs are layers or table views: "HighwayPointsMeasures"
    SelectLayerByAttribute_management(
        in_layer_or_view="HighwayPointsMeasures",
        selection_type="NEW_SELECTION",
        where_clause=
        """SUBSTRING( "RID", 1, 7) NOT  LIKE SUBSTRING("StateKey1", 1, 7)""")

    DeleteRows_management(in_rows="HighwayPointsMeasures")

    MakeRouteEventLayer_lr("SRND_NPD",
                           "NE_UNIQUE",
                           "HighwayPointsMeasures",
                           "rid POINT MEAS",
                           "HighwayPointEvents",
                           offset_field="Distance",
                           add_error_field="ERROR_FIELD",
                           add_angle_field="ANGLE_FIELD",
                           angle_type="NORMAL",
                           complement_angle="ANGLE",
                           offset_direction="RIGHT",
                           point_event_type="POINT")

    #select the secondary direction points
    MakeFeatureLayer_management("HighwayPointEvents", "NPD_ID",
                                """"Distance">=0""")

    # some random points, due to the 500 ft buffer I think, are getting included.  Select the event points that do not intersect a state highway road centerline feature
    #
    SelectLayerByLocation_management(in_layer="NPD_ID",
                                     overlap_type="INTERSECT",
                                     select_features="RoadCenterlines",
                                     search_distance="1 Feet",
                                     selection_type="NEW_SELECTION",
                                     invert_spatial_relationship="INVERT")

    FeatureClassToFeatureClass_conversion(
        "NPD_ID",
        "Database Connections/Conflation2012_sde.sde/Conflation.SDE.KANSAS_DOT",
        "Non_Primary_Divided_Highway", '"Distance">=0')
Esempio n. 25
0
rows = SearchCursor(routelyr)

for row in rows:
    print(row.getValue(IDfield))
    idc = str(row.getValue(IDfield)).replace("-", "_")
    print idc
    rfcx = str(row.getValue(IDfield)) + "_SRND"
    rfc = str(rfcx).replace("-", "_")
    print str(rfc)
    MakeFeatureLayer_management(
        routelyr, rfc, IDfield + " LIKE '" + row.getValue(IDfield) + "'")
    FeatureClassToGeodatabase_conversion(rfc, outws)
    FeatureVerticesToPoints_management(rfc, outws + "/" + idc + "_VP", "ALL")
    LocateFeaturesAlongRoutes_lr(outws + "/" + idc + "_VP", rfc, IDfield,
                                 "0 DecimalDegrees",
                                 outws + "/" + idc + "_CPT",
                                 "NE_UNIQUE POINT AASHTO_MEAS", "FIRST",
                                 "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
    DeleteIdentical_management(outws + "/" + idc + "_CPT",
                               "NE_UNIQUE;AASHTO_MEAS", "#", "0")
    Statistics_analysis(outws + "/" + idc + "_CPT",
                        outws + "/" + idc + "_ENDS",
                        "AASHTO_MEAS MIN;AASHTO_MEAS MAX", "NE_UNIQUE")
    AddJoin_management(idc + "_SRND", IDfield, outws + "/" + idc + "_ENDS",
                       IDfield, "KEEP_ALL")
    CreateRoutes_lr(idc + "_SRND", IDfield, outws + "/" + idc, "TWO_FIELDS",
                    idc + "_ENDS.MAX_AASHTO_MEAS",
                    idc + "_ENDS.MIN_AASHTO_MEAS", "UPPER_LEFT", "1", "0",
                    "IGNORE", "INDEX")
    MakeRouteEventLayer_lr(outws + "/" + idc + "_SRND", IDfield,
                           outws + "/" + idc + "_CPT",