Beispiel #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"
Beispiel #2
0
def MakeRouteLayers(OpEnvironmentMode):
    from EXOR_GIS_CONFIG import OpEnvironment
    OpRunIn= OpEnvironment.OpRunInRoutes  # @UndefinedVariable
    OpRunOut= OpEnvironment.OpRunOut  # @UndefinedVariable
    #adm=OpEnvironment.adm  # @UndefinedVariable
    Owner=OpEnvironment.Owner  # @UndefinedVariable
    DB=OpEnvironment.DB  # @UndefinedVariable
    
    env.workspace = OpRunIn
    env.overwriteOutput = True
    print OpRunIn
    
    #combine the connection, db, and owner to the destination path for enterprise geodatabase output
    OpRunFullOut = OpRunOut+r"/"+DB+"."+Owner+"."
    
    print "Updating CRND"
    #add the Map Extract Event Table limited to primary direction into memory
    TruncateTable_management(OpRunFullOut+"CRND")
    Append_management("CRND", OpRunFullOut+"CRND", "NO_TEST")
    print "Updating SRND"
    TruncateTable_management(OpRunFullOut+"SRND")
    Append_management("SRND", OpRunFullOut+"SRND", "NO_TEST")
    print "Updating NSND"
    TruncateTable_management(OpRunFullOut+"NSND")
    Append_management("NSND", OpRunFullOut+"NSND", "NO_TEST")  
        
    if GetCount_management("MAP_EXTRACT")>0:
        MakeTableView_management("MAP_EXTRACT", "V_MV_MAP_EXTRACT", "DIRECTION < 3")
    
        #Add the CRND CANSYS rotue layer, dynseg the event table, truncate and load to CMLRS
        MakeFeatureLayer_management("CRND", "CRND")
        MakeRouteEventLayer_lr("CRND", "NE_UNIQUE", "MAP_EXTRACT", "NQR_DESCRIPTION LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE", "CMLRS1", "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
        try:
            print "truncation and appending the CMLRS"
            TruncateTable_management(OpRunFullOut+"CMLRS")
            Append_management("CMLRS1", OpRunFullOut+"CMLRS", "NO_TEST")
        except:
            print "could not truncate, overwriting CMLRS"
            FeatureClassToFeatureClass_conversion("CMLRS1", OpRunOut, "CMLRS","#", "#", "#")
        #except:
        #    print "could not update the CMLRS"
        
        MakeFeatureLayer_management("SRND", "SRND")
        MakeRouteEventLayer_lr("SRND", "NE_UNIQUE", "MAP_EXTRACT", "STATE_NQR_DESCRIPTION LINE BEG_STATE_LOGMILE END_STATE_LOGMILE", out_layer="SMLRS1", 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")
        try:
            print "truncation and appending the SMLRS"
            TruncateTable_management(OpRunFullOut+"SMLRS")
            Append_management("SMLRS1", OpRunFullOut+"SMLRS", "NO_TEST")
        except:
            print "could not truncate, overwriting SMLRS"
            FeatureClassToFeatureClass_conversion("SMLRS1", OpRunOut, "SMLRS","#", "#", "#")
        #except:
        #    print "could not update the SMLRS" 
        
        print "Route Layers Updated"
    else: 
        print "the map extract is unreliable and was not exported"
Beispiel #3
0
def CITY ():
    itemname = "CITY"
    cantbl = itemname+"_ln_1"
    
    domname0 = 'CITY_TYPE'
    domstate = """IAL_DOMAIN = 'CITY_TYPE' AND IAL_END_DATE is NULL"""
    domfields = "CT_CITY_NBRR_INCORPORATED_CITY"
    domtbl = itemname+"_"+domfields
    disfields = domfields
    
    domname = "CT_CITY_NBR"
  
    MakeTableView_management("Database Connections/ATLASPROD.odc/V_NM_CTY",domname)
    TableToTable_conversion(domname, wsouttbl, domname+"R", "#")
    MakeTableView_management(wsouttbl+"//"+cantbl,itemname+"PD",""""NE_OWNER" IN ( 'EB' , 'NB' )""","#")
    DissolveRouteEvents_lr(itemname+"PD","LRS_ROUTE LINE Beg_State_Logmile End_State_Logmile", "CITY_NBR", wsouttbl+"//"+itemname+"_SD","LRS_ROUTE LINE Beg_State_Logmile End_State_Logmile","CONCATENATE","INDEX")
    AddIndex_management(wsouttbl+"//"+itemname+"_SD","CITY_NBR","CITY_NBR","NON_UNIQUE","NON_ASCENDING")
    AddField_management(wsouttbl+"//"+domname+"R", "CITY_NBR", "FLOAT", "#", "#", "#")
    CalculateField_management(wsouttbl+"//"+domname+"R", "CITY_NBR", "[CITY_NUMBER]", "VB")
    MakeTableView_management(wsouttbl+"//"+itemname+"_SD", itemname+"_view", "#")
    AddJoin_management(itemname+"_view", "CITY_NBR", wsouttbl+"//"+domname+"R", "CITY_NBR", "KEEP_ALL")
    TableToTable_conversion(itemname+"_view", wsouttbl, itemname+"_EVENT", "#")
    
    AssignDomainToField_management(wsouttbl+"//"+itemname+"_EVENT",domfields,domname0)
    
    DeleteField_management(wsouttbl+"//"+itemname+"_EVENT","CTYR_OBJECTID;CTYR_IIT_NE_ID;CTYR_IIT_INV_TYPE;CTYR_IIT_PRIMARY_KEY;CTYR_IIT_START_DATE;CTYR_IIT_DATE_CREATED;CTYR_IIT_DATE_MODIFIED;CTYR_IIT_CREATED_BY;CTYR_IIT_MODIFIED_BY;CTYR_IIT_ADMIN_UNIT;CTYR_IIT_NOTE;CTYR_IIT_PEO_INVENT_BY_ID;CTYR_NAU_UNIT_CODE;CTYR_IIT_END_DATE;CTYR_CITY_NBR")
    MakeRouteEventLayer_lr(wsouttbl+"//SMLRS","LRS_ROUTE",wsouttbl+"//"+itemname+"_EVENT","LRS_ROUTE LINE Beg_State_Logmile End_State_Logmile",itemname+"_ITEM","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    FeatureClassToFeatureClass_conversion(itemname+"_ITEM", wsouttbl, itemname)
    DeleteField_management(wsouttbl+"//"+itemname,"CTYR_OBJECTID;CTYR_IIT_NE_ID;CTYR_IIT_INV_TYPE;CTYR_IIT_PRIMARY_KEY;CTYR_IIT_START_DATE;CTYR_IIT_DATE_CREATED;CTYR_IIT_DATE_MODIFIED;CTYR_IIT_CREATED_BY;CTYR_IIT_MODIFIED_BY;CTYR_IIT_ADMIN_UNIT;CTYR_IIT_NOTE;CTYR_IIT_PEO_INVENT_BY_ID;CTYR_NAU_UNIT_CODE;CTYR_IIT_END_DATE;CTYR_CITY_NBR")
    print "we have cities"
Beispiel #4
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."
Beispiel #5
0
def INTR ():
    TableToTable_conversion("INTR_pt_1",wsouttbl,"INTR_pt_2","#","""LRS_KEY "LRS_KEY" true true false 13 Text 0 0 ,First,#,INTR_pt_1,LRS_KEY,-1,-1;Cnty_Logmile "Cnty_Logmile" true true false 8 Double 0 0 ,First,#,INTR_pt_1,Cnty_Logmile,-1,-1;Distance "Distance" true true false 8 Double 0 0 ,First,#,INTR_pt_1,Distance,-1,-1;IIT_NE_ID "IIT_NE_ID" true false false 4 Long 0 0 ,First,#,INTR_pt_1,IIT_NE_ID,-1,-1;IIT_INV_TYPE "IIT_INV_TYPE" true false false 4 Text 0 0 ,First,#,INTR_pt_1,IIT_INV_TYPE,-1,-1;IIT_PRIMARY_KEY "IIT_PRIMARY_KEY" true false false 50 Text 0 0 ,First,#,INTR_pt_1,IIT_PRIMARY_KEY,-1,-1;IIT_START_DATE "IIT_START_DATE" true false false 8 Date 0 0 ,First,#,INTR_pt_1,IIT_START_DATE,-1,-1;IIT_DATE_CREATED "IIT_DATE_CREATED" true false false 8 Date 0 0 ,First,#,INTR_pt_1,IIT_DATE_CREATED,-1,-1;IIT_DATE_MODIFIED "IIT_DATE_MODIFIED" true false false 8 Date 0 0 ,First,#,INTR_pt_1,IIT_DATE_MODIFIED,-1,-1;IIT_CREATED_BY "IIT_CREATED_BY" true false false 30 Text 0 0 ,First,#,INTR_pt_1,IIT_CREATED_BY,-1,-1;IIT_MODIFIED_BY "IIT_MODIFIED_BY" true false false 30 Text 0 0 ,First,#,INTR_pt_1,IIT_MODIFIED_BY,-1,-1;IIT_ADMIN_UNIT "IIT_ADMIN_UNIT" true false false 4 Long 0 0 ,First,#,INTR_pt_1,IIT_ADMIN_UNIT,-1,-1;IIT_DESCR "IIT_DESCR" true true false 40 Text 0 0 ,First,#,INTR_pt_1,IIT_DESCR,-1,-1;IIT_NOTE "IIT_NOTE" true true false 40 Text 0 0 ,First,#,INTR_pt_1,IIT_NOTE,-1,-1;IIT_PEO_INVENT_BY_ID "IIT_PEO_INVENT_BY_ID" true true false 4 Long 0 0 ,First,#,INTR_pt_1,IIT_PEO_INVENT_BY_ID,-1,-1;NAU_UNIT_CODE "NAU_UNIT_CODE" true true false 10 Text 0 0 ,First,#,INTR_pt_1,NAU_UNIT_CODE,-1,-1;IIT_END_DATE "IIT_END_DATE" true true false 8 Date 0 0 ,First,#,INTR_pt_1,IIT_END_DATE,-1,-1;INTRSCTN_NAME "INTRSCTN_NAME" true true false 50 Text 0 0 ,First,#,INTR_pt_1,INTRSCTN_NAME,-1,-1;ON_STATE_NONSTATE "ON_STATE_NONSTATE" true true false 16 Text 0 0 ,First,#,INTR_pt_1,ON_STATE_NONSTATE,-1,-1;INTRSCTN_DESC "INTRSCTN_DESC" true true false 200 Text 0 0 ,First,#,INTR_pt_1,INTRSCTN_DESC,-1,-1;INTRSCTN_ID "INTRSCTN_ID" true false false 50 Text 0 0 ,First,#,INTR_pt_1,INTRSCTN_ID,-1,-1;TFO_IND "TFO_IND" true true false 1 Text 0 0 ,First,#,INTR_pt_1,TFO_IND,-1,-1;CART_NODE_ID "CART_NODE_ID" true true false 4 Long 0 0 ,First,#,INTR_pt_1,CART_NODE_ID,-1,-1;LEFT_TURN_LN "LEFT_TURN_LN" true true false 4 Long 0 0 ,First,#,INTR_pt_1,LEFT_TURN_LN,-1,-1;RIGHT_TURN_LN "RIGHT_TURN_LN" true true false 4 Long 0 0 ,First,#,INTR_pt_1,RIGHT_TURN_LN,-1,-1;INTERSECTION_CONTROL "INTERSECTION_CONTROL" true true false 4 Long 0 0 ,First,#,INTR_pt_1,INTERSECTION_CONTROL,-1,-1;PER_GREEN_TIME "PER_GREEN_TIME" true true false 4 Double 0 0 ,First,#,INTR_pt_1,PER_GREEN_TIME,-1,-1;LONGITUDE "LONGITUDE" true true false 4 Float 0 0 ,First,#,INTR_pt_1,LONGITUDE,-1,-1;LATITUDE "LATITUDE" true true false 4 Float 0 0 ,First,#,INTR_pt_1,LATITUDE,-1,-1;NM_NE_ID_IN "NM_NE_ID_IN" true false false 4 Long 0 0 ,First,#,INTR_pt_1,NM_NE_ID_IN,-1,-1;NM_NE_ID_OF "NM_NE_ID_OF" true false false 4 Long 0 0 ,First,#,INTR_pt_1,NM_NE_ID_OF,-1,-1;NM_TYPE "NM_TYPE" true false false 4 Text 0 0 ,First,#,INTR_pt_1,NM_TYPE,-1,-1;NM_OBJ_TYPE "NM_OBJ_TYPE" true false false 4 Text 0 0 ,First,#,INTR_pt_1,NM_OBJ_TYPE,-1,-1;NM_BEGIN_MP "NM_BEGIN_MP" true false false 8 Double 0 0 ,First,#,INTR_pt_1,NM_BEGIN_MP,-1,-1;NM_START_DATE "NM_START_DATE" true false false 8 Date 0 0 ,First,#,INTR_pt_1,NM_START_DATE,-1,-1;NM_END_DATE "NM_END_DATE" true true false 8 Date 0 0 ,First,#,INTR_pt_1,NM_END_DATE,-1,-1;NM_END_MP "NM_END_MP" true false false 8 Double 0 0 ,First,#,INTR_pt_1,NM_END_MP,-1,-1;NM_SLK "NM_SLK" true true false 8 Double 0 0 ,First,#,INTR_pt_1,NM_SLK,-1,-1;NM_CARDINALITY "NM_CARDINALITY" true true false 8 Double 0 0 ,First,#,INTR_pt_1,NM_CARDINALITY,-1,-1;NM_ADMIN_UNIT "NM_ADMIN_UNIT" true false false 4 Long 0 0 ,First,#,INTR_pt_1,NM_ADMIN_UNIT,-1,-1;NM_DATE_CREATED "NM_DATE_CREATED" true true false 8 Date 0 0 ,First,#,INTR_pt_1,NM_DATE_CREATED,-1,-1;NM_DATE_MODIFIED "NM_DATE_MODIFIED" true true false 8 Date 0 0 ,First,#,INTR_pt_1,NM_DATE_MODIFIED,-1,-1;NM_MODIFIED_BY "NM_MODIFIED_BY" true true false 30 Text 0 0 ,First,#,INTR_pt_1,NM_MODIFIED_BY,-1,-1;NM_CREATED_BY "NM_CREATED_BY" true true false 30 Text 0 0 ,First,#,INTR_pt_1,NM_CREATED_BY,-1,-1;NM_SEQ_NO "NM_SEQ_NO" true true false 8 Double 0 0 ,First,#,INTR_pt_1,NM_SEQ_NO,-1,-1;NM_SEG_NO "NM_SEG_NO" true true false 4 Long 0 0 ,First,#,INTR_pt_1,NM_SEG_NO,-1,-1;NM_TRUE "NM_TRUE" true true false 8 Double 0 0 ,First,#,INTR_pt_1,NM_TRUE,-1,-1;NM_END_SLK "NM_END_SLK" true true false 8 Double 0 0 ,First,#,INTR_pt_1,NM_END_SLK,-1,-1;NM_END_TRUE "NM_END_TRUE" true true false 8 Double 0 0 ,First,#,INTR_pt_1,NM_END_TRUE,-1,-1;NE_ID "NE_ID" true false false 4 Long 0 0 ,First,#,INTR_pt_1,NE_ID,-1,-1;NE_UNIQUE "NE_UNIQUE" true false false 30 Text 0 0 ,First,#,INTR_pt_1,NE_UNIQUE,-1,-1;NE_TYPE "NE_TYPE" true false false 4 Text 0 0 ,First,#,INTR_pt_1,NE_TYPE,-1,-1;NE_NT_TYPE "NE_NT_TYPE" true false false 4 Text 0 0 ,First,#,INTR_pt_1,NE_NT_TYPE,-1,-1;NE_DESCR "NE_DESCR" true false false 240 Text 0 0 ,First,#,INTR_pt_1,NE_DESCR,-1,-1;NE_LENGTH "NE_LENGTH" true true false 8 Double 0 0 ,First,#,INTR_pt_1,NE_LENGTH,-1,-1;NE_ADMIN_UNIT "NE_ADMIN_UNIT" true false false 4 Long 0 0 ,First,#,INTR_pt_1,NE_ADMIN_UNIT,-1,-1;NE_DATE_CREATED "NE_DATE_CREATED" true false false 8 Date 0 0 ,First,#,INTR_pt_1,NE_DATE_CREATED,-1,-1;NE_DATE_MODIFIED "NE_DATE_MODIFIED" true false false 8 Date 0 0 ,First,#,INTR_pt_1,NE_DATE_MODIFIED,-1,-1;NE_MODIFIED_BY "NE_MODIFIED_BY" true false false 30 Text 0 0 ,First,#,INTR_pt_1,NE_MODIFIED_BY,-1,-1;NE_CREATED_BY "NE_CREATED_BY" true false false 30 Text 0 0 ,First,#,INTR_pt_1,NE_CREATED_BY,-1,-1;NE_START_DATE "NE_START_DATE" true false false 8 Date 0 0 ,First,#,INTR_pt_1,NE_START_DATE,-1,-1;NE_END_DATE "NE_END_DATE" true true false 8 Date 0 0 ,First,#,INTR_pt_1,NE_END_DATE,-1,-1;NE_GTY_GROUP_TYPE "NE_GTY_GROUP_TYPE" true true false 4 Text 0 0 ,First,#,INTR_pt_1,NE_GTY_GROUP_TYPE,-1,-1;NE_OWNER "NE_OWNER" true true false 4 Text 0 0 ,First,#,INTR_pt_1,NE_OWNER,-1,-1;NE_NAME_1 "NE_NAME_1" true true false 80 Text 0 0 ,First,#,INTR_pt_1,NE_NAME_1,-1,-1;NE_NAME_2 "NE_NAME_2" true true false 80 Text 0 0 ,First,#,INTR_pt_1,NE_NAME_2,-1,-1;NE_PREFIX "NE_PREFIX" true true false 4 Text 0 0 ,First,#,INTR_pt_1,NE_PREFIX,-1,-1;NE_NUMBER "NE_NUMBER" true true false 8 Text 0 0 ,First,#,INTR_pt_1,NE_NUMBER,-1,-1;NE_SUB_TYPE "NE_SUB_TYPE" true true false 2 Text 0 0 ,First,#,INTR_pt_1,NE_SUB_TYPE,-1,-1;NE_GROUP "NE_GROUP" true true false 30 Text 0 0 ,First,#,INTR_pt_1,NE_GROUP,-1,-1;NE_NO_START "NE_NO_START" true true false 4 Long 0 0 ,First,#,INTR_pt_1,NE_NO_START,-1,-1;NE_NO_END "NE_NO_END" true true false 4 Long 0 0 ,First,#,INTR_pt_1,NE_NO_END,-1,-1;NE_SUB_CLASS "NE_SUB_CLASS" true true false 4 Text 0 0 ,First,#,INTR_pt_1,NE_SUB_CLASS,-1,-1;NE_NSG_REF "NE_NSG_REF" true true false 240 Text 0 0 ,First,#,INTR_pt_1,NE_NSG_REF,-1,-1;NE_VERSION_NO "NE_VERSION_NO" true true false 240 Text 0 0 ,First,#,INTR_pt_1,NE_VERSION_NO,-1,-1""","#")

#convert EXOR domains to SDE Database domains - intersection type
    itemname = 'INTR'
    itemdom = 'IN_INTRSCTN_TYPE'  #IN INTRSCTN_TYPE, TURN_LANE
    newdomname = 'INTRSCTN_TYPE'
    itemsel = """"IAL_DOMAIN" = '"""+itemdom+"'"
    itemdescr = 'Intersection Type'
    
    #convert EXOR domains to SDE Database domains - turn lanes type
    itemdom1 = 'TURN_LANE'  #IN INTRSCTN_TYPE, TURN_LANE
    newdomname1 = 'INTERSECTION_TURN_LANE'
    itemsel1 = """"IAL_DOMAIN" = '"""+itemdom1+"'"
    itemdescr1 = 'Turn Lane Type'
    
    MakeTableView_management(itemname+"_pt_2", itemname+"PD","#","#") 
    print ("Intersections are located on a directional basis in some cases, so primary and secondary directions are allowed until advised differently")
    
    DissolveRouteEvents_lr(itemname+"PD","LRS_Key POINT Cnty_Logmile","IIT_NE_ID;INTRSCTN_NAME;ON_STATE_NONSTATE;INTRSCTN_DESC;INTRSCTN_ID;TFO_IND;CART_NODE_ID;LEFT_TURN_LN;RIGHT_TURN_LN;INTERSECTION_CONTROL;PER_GREEN_TIME;NE_OWNER",wsouttbl+"//"+itemname+"_EVENT","LRS_Key POINT Cnty_Logmile","DISSOLVE","INDEX")
    AssignDomainToField_management(itemname+"_EVENT","INTERSECTION_CONTROL",itemdom)
    AssignDomainToField_management(itemname+"_EVENT","LEFT_TURN_LN",itemdom1)
    AssignDomainToField_management(itemname+"_EVENT","RIGHT_TURN_LN",itemdom1)
    MakeRouteEventLayer_lr("CMLRS","LRS_KEY",itemname+"_EVENT","LRS_Key POINT Cnty_Logmile",itemname+"_ITEM","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    #arcpy.FeatureClassToFeatureClass_conversion(itemname+"_ITEM", wsouttbl, itemname)
    
    lyrlist = ["INTR"]
    for lyr in lyrlist:
        lyrin = lyr+"_ITEM"#    
        FeatureClassToFeatureClass_conversion(lyrin, ws+"\\"+tempgdb,lyr) #23 sec
Beispiel #6
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"
Beispiel #7
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")
Beispiel #8
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", "#")
Beispiel #9
0
def MapHPMS_Events():
    env.workspace = HPMS_DATA
    tableList = ListTables()

    for table in tableList:
        intable = HPMS_DATA + r"/" + table
        outname = str(table)
        print "table " + table + " mapping"
        MakeRouteEventLayer_lr("C_Primary_Route", "NQR_DESCRIPTION", intable,
                               "ROUTE_ID LINE END_POINT END_POINT", outname,
                               "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL",
                               "ANGLE", "LEFT", "POINT")
Beispiel #10
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."
Beispiel #11
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")
Beispiel #12
0
def FUN ():
    itemname = 'FUN'
    cantbl = itemname+"_ln_1"
    domname = 'FC_FUN_CLASS'
    domfields = "FUN_CLASS"
    domtbl = itemname+"_"+domfields+"_tbl"
    disfields = domfields
    
    MakeTableView_management(wsouttbl+"//"+cantbl,itemname+"PD",""""NE_OWNER" IN ( 'EB' , 'NB' )""","#")
    DissolveRouteEvents_lr(itemname+"PD","LRS_KEY LINE Beg_Cnty_Logmile End_Cnty_Logmile",disfields,wsouttbl+"//"+itemname+"_EVENT","LRS_Key LINE Beg_Cnty_Logmile End_Cnty_Logmile","CONCATENATE","INDEX")
    AssignDomainToField_management(wsouttbl+"//"+itemname+"_EVENT",domfields,domname)
    MakeRouteEventLayer_lr(wsouttbl+"//CMLRS","LRS_KEY",wsouttbl+"//"+itemname+"_EVENT","LRS_Key LINE Beg_Cnty_Logmile End_Cnty_Logmile",itemname+"_ITEM","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    FeatureClassToFeatureClass_conversion(itemname+"_ITEM", wsouttbl, itemname)
    
    lyrlist = ["FUN"]
    for lyr in lyrlist:
        lyrin = lyr+"_ITEM"#    
        FeatureClassToFeatureClass_conversion(lyrin, ws+"\\"+tempgdb,lyr) #23 sec
Beispiel #13
0
def UAB():
    itemname = "UAB"
    cantbl = itemname+"_ln_1"
    domname = "UABR"
    
    MakeTableView_management("Database Connections/ATLASPROD.odc/V_NM_UABR",domname)
    
    TableToTable_conversion(domname, wsouttbl, domname+"R", "#")
    MakeTableView_management(wsouttbl+"//"+cantbl,itemname+"PD",""""NE_OWNER" IN ( 'EB' , 'NB' )""","#")
    DissolveRouteEvents_lr(itemname+"PD","LRS_ROUTE LINE Beg_State_Logmile End_State_Logmile", "CITY_NBR", wsouttbl+"//"+itemname+"_SD","LRS_ROUTE LINE Beg_State_Logmile End_State_Logmile","CONCATENATE","INDEX")
    AddIndex_management(wsouttbl+"//"+itemname+"_SD","CITY_NBR","CITY_NBR","NON_UNIQUE","NON_ASCENDING")
    AddField_management(wsouttbl+"//"+domname+"R", "CITY_NBR", "FLOAT", "#", "#", "#")
    CalculateField_management(wsouttbl+"//"+domname+"R", "CITY_NBR", "[CITY_NUMBER]", "VB")
    MakeTableView_management(wsouttbl+"//"+itemname+"_SD", itemname+"_view", "#")
    AddJoin_management(itemname+"_view", "CITY_NBR", wsouttbl+"//"+domname+"R", "CITY_NBR", "KEEP_ALL")
    TableToTable_conversion(itemname+"_view", wsouttbl, domname+"J", "#")
    MakeRouteEventLayer_lr(wsouttbl+"//SMLRS","LRS_ROUTE",wsouttbl+"//"+domname+"J","LRS_ROUTE LINE Beg_State_Logmile End_State_Logmile",itemname+"_ITEM","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    FeatureClassToFeatureClass_conversion(itemname+"_ITEM", wsouttbl, itemname)
    print "we have UABs"
Beispiel #14
0
def AnnualStats(ShapeFileDate):
    env.overwriteOutput = 1
    #SourceFileTxt = str(ShapeFileDate[12:-4].replace("-", ""))
    #infileMonthly = yeardb+r"\Kansas\LRS"+SourceFileTxt
    qyear = ShapeFileDate[16:20]
    #try:
    #    Delete_management(yeardb+"/KTRIPS_MonthlySum_Statistics")
    #    Delete_management(yeardb+"/RunningTotal")
    #except:
    #    print "nothing deleted"
    #sumfile = gdb+"\INTERMODAL.DBO.KTRIPS_MonthlySum"
    sumfile = gdb + "\KTRIPS.SDE.KTRIPS_MonthlySum"
    whereclause = str(BuildWhereClauseLike(sumfile, "SourceFile", qyear))
    if Exists("ThisYearMonthly"):
        Delete_management("ThisYearMonthly")
    MakeFeatureLayer_management(sumfile, "ThisYearMonthly", whereclause, "#",
                                "#")
    Statistics_analysis("ThisYearMonthly",
                        "in_memory/KTRIPS_MonthlySum_Statistics",
                        "Join_Count SUM;Tonnage SUM",
                        "LRS_KEY;BEG_CNTY_LOGMILE;END_CNTY_LOGMILE")
    AddField_management("in_memory/KTRIPS_MonthlySum_Statistics", "TonMiles",
                        "DOUBLE", "#", "#", "#", "#", "NULLABLE",
                        "NON_REQUIRED", "#")
    CalculateField_management(
        "in_memory/KTRIPS_MonthlySum_Statistics", "TonMiles",
        "!SUM_Tonnage! /(!END_CNTY_LOGMILE! - !BEG_CNTY_LOGMILE!)",
        "PYTHON_9.3", "#")
    if Exists("KTRIPS_RunningTotal_CurentYear"):
        Delete_management("KTRIPS_RunningTotal_CurentYear")
    MakeRouteEventLayer_lr(cansys, "LRS_KEY",
                           "in_memory/KTRIPS_MonthlySum_Statistics",
                           "LRS_KEY LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE",
                           "KTRIPS_RunningTotal_CurentYear", "#",
                           "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE",
                           "LEFT", "POINT")
    CurrentYrStat = gdb + "\KTRIPS.SDE.Ktrips_CurrentYear"
    TruncateTable_management(CurrentYrStat)
    Append_management("KTRIPS_RunningTotal_CurentYear", CurrentYrStat,
                      "NO_TEST", "#", "")
    print "annual Stats have been recalculated from the latest Monthly Statistics"
    Delete_management("in_memory/KTRIPS_MonthlySum_Statistics")
Beispiel #15
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."
Beispiel #16
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")
Beispiel #17
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")
Beispiel #18
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')
Beispiel #19
0
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",
                      "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("SECT",STAGEDB,"CANSYS_SECTIONS", "#", "#"  )

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

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





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")
MakeTableView_management(ws+"\\"+tempgdb+"/CP_SRND","Calibration_SR",'"STATE_MILE" = "SRND"', ws+"\\"+tempgdb,"#")
MakeRouteEventLayer_lr(routelyr,"NE_UNIQUE","Calibration_SR","STATE_MILE POINT SR_MEAS","SR_Calibration_Events","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
FeatureClassToFeatureClass_conversion("SR_Calibration_Events",ws+"\\"+tempgdb,"Calibration_Points_SRND","#","#")
DeleteIdentical_management(ws+"\\"+tempgdb+"/Calibration_Points_SRND","STATE_MILE;SR_MEAS","0.002 Miles","0")
CreateRoutes_lr(ws+"\\"+tempgdb+"/State_System","LRS_ROUTE",ws+"\\"+tempgdb+"/StateSystem_State_Route_SRND","TWO_FIELDS","BEG_STATE_LOGMILE","END_STATE_LOGMILE","UPPER_LEFT","1","0","IGNORE","INDEX")
CalibrateRoutes_lr(ws+"\\"+tempgdb+"/StateSystem_State_Route_"+route,"LRS_ROUTE",ws+"\\"+tempgdb+"/Calibration_Points_SRND","LRS_ROUTE","SR_MEAS",ws+"\\"+tempgdb+"/SMLRS","MEASURES","5 feet","BETWEEN","BEFORE","AFTER","IGNORE","KEEP","INDEX")
AddField_management(ws+"\\"+tempgdb+"/SMLRS", "NETWORKDATE", "DATE")
CalculateField_management(ws+"\\"+tempgdb+"/SMLRS","NETWORKDATE","datetime.datetime.now( )","PYTHON_9.3","#")

route = "CRND"
routelyr = ws+"\\"+tempgdb+"\\"+route
LocateFeaturesAlongRoutes_lr(ws+"\\"+tempgdb+"/Calibration_Points",ws+"\\"+tempgdb+"/CRND","NE_UNIQUE","0.001 Feet",ws+"\\"+tempgdb+"/CP_CRND","STATE_MILE POINT CR_MEAS","ALL","DISTANCE","ZERO","FIELDS","M_DIRECTON")
MakeTableView_management(ws+"\\"+tempgdb+"/CP_CRND","Calibration_CR",'"STATE_MILE" = "CRND"', ws+"\\"+tempgdb,"#")
MakeRouteEventLayer_lr(routelyr,"NE_UNIQUE","Calibration_CR","STATE_MILE POINT CR_MEAS","CR_Calibration_Events","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
FeatureClassToFeatureClass_conversion("CR_Calibration_Events",ws+"\\"+tempgdb,"Calibration_Points_CRND","#","#")
DeleteIdentical_management(ws+"\\"+tempgdb+"/Calibration_Points_CRND","STATE_MILE;CR_MEAS","0.002 Miles","0")
CreateRoutes_lr(ws+"\\"+tempgdb+"/State_System","LRS_KEY",ws+"\\"+tempgdb+"/StateSystem_County_Route_CRND","TWO_FIELDS","BEG_CNTY_LOGMILE","END_CNTY_LOGMILE","UPPER_LEFT","1","0","IGNORE","INDEX")
Beispiel #21
0
                           "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"
domname = 'FC_FUN_CLASS'
domfields = "FUN_CLASS"
disfields = domfields
Beispiel #22
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"
Beispiel #23
0
#Add map extract table
MapExtract = STAGEDB + r'\MAP_EXTRACT'
primdir = "DIRECTION < 4"
MakeTableView_management(MapExtract, "MapExtract", primdir)

#calcualte the SRND KEY from the Map Extract Fields
AddField_management("MapExtract", "SRND_KEY", "TEXT", "", "", "24", "",
                    "NULLABLE", "NON_REQUIRED")
CalculateField_management("MapExtract", "SRND_KEY", "!NQR_DESCRIPTION![3:]",
                          "PYTHON", "#")

#Make route event layer from the extract table
MakeFeatureLayer_management(STAGEDB + r"\SRND_PRIMARY", "SRND_PRIMARY")
MakeRouteEventLayer_lr("SRND_PRIMARY", "NE_UNIQUE", "MapExtract",
                       "SRND_KEY LINE BEG_STATE_LOGMILE END_STATE_LOGMILE",
                       "MapExtractSRNDEvents", "#", "ERROR_FIELD",
                       "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
FeatureClassToFeatureClass_conversion("MapExtractSRNDEvents", STAGEDB,
                                      "GIS_STATE_SYSTEM",
                                      "LOC_ERROR = 'NO ERROR'")

#Copy State System to SDEDEV... problem with Geomedia ability to connect
FeatureClassToFeatureClass_conversion("MapExtractSRNDEvents", SDEDEV_SHARED,
                                      "STATE_SYSTEM", "LOC_ERROR = 'NO ERROR'")

#copy state systen to GISTEST
FeatureClassToFeatureClass_conversion("MapExtractSRNDEvents",
                                      "Database Connections/GISTEST.sde",
                                      "STATE_SYSTEM", "#", "#", "SDO_GEOMETRY")

#Save the Primary Route Skeleton Layer
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')
Beispiel #25
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"
Beispiel #26
0
Non_State_Roads = r"\\gisdata\arcgis\GISdata\Connection_files\[email protected]\SHARED.NON_STATE_SYSTEM"
Non_State_Sections = r"\\gisdata\arcgis\GISdata\Connection_files\[email protected]\SHARED.NON_STATE_SECTIONS"

#import cx_Oracle
#con = cx_Oracle.connect('shared/gis@sdeprod')
# here, explore using cx_Oracle to run/commit the following SQL Query

#update  NON_STATE_SECTIONS S
#set S.END_MP = S.milepost+ S.length
#where (ABS(S.END_MP - (S.MILEPOST+ S.LENGTH))) >= 0.001 or S.END_MP is null

#print con.version
#con.close()

FeatureClassToFeatureClass_conversion(Non_State_Roads, "in_memory",
                                      "Rural_Major_Collectors",
                                      "LRS_KEY like '%R%'")
MakeFeatureLayer_management("Rural_Major_Collectors",
                            "Rural_Major_Collectors_Flips",
                            """"LRS_BACKWARDS" <0""")
FlipLine_edit("Rural_Major_Collectors_Flips")
CreateRoutes_lr("Rural_Major_Collectors", "LRS_KEY", "in_memory/RMC_Routes",
                "TWO_FIELDS", "LRS_BEG_CNTY_LOGMILE", "LRS_END_CNTY_LOGMILE",
                "UPPER_LEFT", "1", "0", "IGNORE", "INDEX")
MakeRouteEventLayer_lr("RMC_Routes", "LRS_KEY", Non_State_Sections,
                       "LRS_KEY LINE MILEPOST END_MP", "NON_STATE_SECTIONS",
                       "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE",
                       "LEFT", "POINT")
MakeFeatureLayer_management("NON_STATE_SECTIONS", "HP_Colls",
                            "HPMS is not null AND SUPERCEDEDASOF IS NULL")
Beispiel #27
0
def MonthlyStats(ShapeFileDate):
    env.overwriteOutput = 1
    qyear = ShapeFileDate[16:20]
    qmonth = ShapeFileDate[13:15]
    print "summarizing month " + str(qmonth) + " of year " + str(qyear)
    lyrQuery = 'DATEPART("YYYY", START_DT) = ' + str(
        qyear) + ' AND DATEPART("MM", START_DT) = ' + str(qmonth)
    outlyr = "KTRIPS" + str(qyear) + str(qmonth).zfill(2)
    lyr = gdboutpath + ".KTRIPS_ROUTES"
    if Exists(outlyr):
        Delete_management(outlyr)
    else:
        pass

    MakeFeatureLayer_management(lyr, outlyr, lyrQuery)
    IntersectSum = 'in_memory/Intsum' + outlyr
    IntersectPt = "in_memory/Intpt" + outlyr
    #TripSum = monthdb+'\Seg'+outlyr
    TripSum2 = 'in_memory\Seg' + outlyr
    BISum2 = 'in_memory\BI' + outlyr
    infc = outlyr
    #config the intersection path
    Intersections = gdb + "\KTRIPS.SDE.IntrCounter2014"
    Routes = gdb + "\KTRIPS.SDE.RouteCounter2014"
    field_mapping1 = 'SourceFile "SourceFile" true true false 50 Text 0 0 ,Last,#,' + infc + ',SourceFile,-1,-1; Tonnage "Tonnage" true true false 8 Double 0 0 ,Sum,#,' + infc + ',Tonnage,-1,-1'
    SpatialJoin_analysis(Intersections, infc, IntersectSum, "JOIN_ONE_TO_ONE",
                         "KEEP_COMMON", field_mapping1, "INTERSECT", "#", "#")
    field_mapping2 = 'LRS_KEY "LRS_KEY" true true false 13 Text 0 0 ,First,#,' + Routes + ',LRS_KEY,-1,-1;BEG_CNTY_LOGMILE "BEG_CNTY_LOGMILE" true true false 8 Double 3 9 ,Min,#,' + Routes + ',BEG_CNTY_LOGMILE,-1,-1;END_CNTY_LOGMILE "END_CNTY_LOGMILE" true true false 8 Double 3 9 ,Max,#,' + Routes + ',END_CNTY_LOGMILE,-1,-1;SourceFile "SourceFile" true true false 50 Text 0 0 ,Last,#,' + infc + ',SourceFile,-1,-1;Tonnage "Tonnage" true true false 8 Double 0 0 ,Sum, #,' + infc + ',Tonnage,-1,-1'
    SpatialJoin_analysis(Routes, infc, TripSum2, "JOIN_ONE_TO_ONE",
                         "KEEP_COMMON", field_mapping2, "INTERSECT", "#", "#")
    AddField_management(TripSum2, "TonMile", "DOUBLE", "#", "1", "#",
                        "Tons Per Mile", "NULLABLE", "NON_REQUIRED", "#")
    CalculateField_management(
        TripSum2, "TonMile",
        "!Tonnage! /( !END_CNTY_LOGMILE!- !BEG_CNTY_LOGMILE!)", "PYTHON_9.3",
        "#")
    AddField_management(TripSum2, "START_DATE", "DATE", "#", "#", "#", "#",
                        "NULLABLE", "NON_REQUIRED", "#")
    AddField_management(IntersectSum, "START_DATE", "DATE", "#", "#", "#", "#",
                        "NULLABLE", "NON_REQUIRED", "#")
    dateexpress = "'" + qmonth + "/" + qyear + "'"
    CalculateField_management(TripSum2, "START_DATE", dateexpress,
                              "PYTHON_9.3", "#")
    CalculateField_management(IntersectSum, "START_DATE", dateexpress,
                              "PYTHON_9.3", "#")
    # 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: "KTRIPS.SDE.KTRIPS_ROUTES", "KTRIPS.SDE.RouteCounter2014"
    SpatialJoin_analysis(outlyr,
                         Routes,
                         r"in_memory\DWBI_SEGS_SPATIAL",
                         "JOIN_ONE_TO_MANY",
                         "KEEP_ALL",
                         "#",
                         match_option="INTERSECT",
                         search_radius="",
                         distance_field_name="")
    MakeTableView_management(r"in_memory\DWBI_SEGS_SPATIAL", "DWBI_SEGS")
    #Delete_management(r"in_memory\DWBI_SEGS_SPATIAL")
    #Add BI segmentation here
    #SpatialJoin_analysis(Routes,infc,TripSum2,"JOIN_ONE_TO_ONE","KEEP_COMMON",field_mapping2,"INTERSECT","#","#")

    #outtbl = "tbl"+str(qyear)+str(qmonth).zfill(2)
    #TableToTable_conversion(TripSum2,"in_memory",outtbl,"#","#","#")
    outtbl = TripSum2
    MakeRouteEventLayer_lr(cansys, "LRS_KEY", outtbl,
                           "LRS_KEY LINE BEG_CNTY_LOGMILE END_CNTY_LOGMILE",
                           "LRS", "#", "ERROR_FIELD", "NO_ANGLE_FIELD",
                           "NORMAL", "ANGLE", "LEFT", "POINT")
    FeatureClassToFeatureClass_conversion(
        "LRS", "in_memory", "LRS" + str(qmonth) + str(qyear).zfill(2))
    FeatureToPoint_management(IntersectSum, IntersectPt, "CENTROID")
    print "monthly summary complete"
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))
Beispiel #29
0
SRNDelem = "NE_NT_TYPE = 'SRND' AND NE_END_DATE IS NULL 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")
FeatureClassToFeatureClass_conversion("SRND", STAGEDB, "SRND_PRIMARY" )

#Add map extract table
MapExtract = STAGEDB+r'\MAP_EXTRACT'
primdir = "DIRECTION < 4"
MakeTableView_management(MapExtract, "MapExtract",  primdir)

#calcualte the SRND KEY from the Map Extract Fields
AddField_management("MapExtract", "SRND_KEY", "TEXT", "", "", "24", "", "NULLABLE", "NON_REQUIRED")
CalculateField_management("MapExtract", "SRND_KEY", "!NQR_DESCRIPTION![3:]", "PYTHON", "#")

#Make route event layer from the extract table
MakeRouteEventLayer_lr("SRND","GIS_CANSYS.DBO.ELEMENTS_ALL.NE_UNIQUE","MapExtract","SRND_KEY LINE BEG_STATE_LOGMILE END_STATE_LOGMILE","MapExtractSRNDEvents","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
FeatureClassToFeatureClass_conversion("MapExtractSRNDEvents", STAGEDB, "GIS_STATE_SYSTEM", "LOC_ERROR = 'NO ERROR'" )
#Save the Primary Route Skeleton Layer

#Create the vertices for calibration points
FeatureVerticesToPoints_management(STAGEDB+"/GIS_STATE_SYSTEM", STAGEDB+"/Calibration_Points","ALL")
DeleteIdentical_management("GIS_CANSYS.DBO.Calibration_Points_SRND","GIS_CANSYS_DBO_SRND_START_D_3;GIS_CANSYS_DBO_SRND_END_DAT_4;GIS_CANSYS_DBO_ELEMENTS_ALL_12;Shape","#","0")  #Succeeded at Tue Dec 17 17:16:10 2013 (Elapsed Time: 21 minutes 55 seconds)

'''

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")
MakeTableView_management(ws+"\\"+tempgdb+"/CP_SRND","Calibration_SR",'"STATE_MILE" = "SRND"', ws+"\\"+tempgdb,"#")
MakeRouteEventLayer_lr(routelyr,"NE_UNIQUE","Calibration_SR","STATE_MILE POINT SR_MEAS","SR_Calibration_Events","#","ERROR_FIELD","NO_ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
FeatureClassToFeatureClass_conversion("SR_Calibration_Events",ws+"\\"+tempgdb,"Calibration_Points_SRND","#","#")

CreateRoutes_lr(ws+"\\"+tempgdb+"/State_System","LRS_ROUTE",ws+"\\"+tempgdb+"/StateSystem_State_Route_SRND","TWO_FIELDS","BEG_STATE_LOGMILE","END_STATE_LOGMILE","UPPER_LEFT","1","0","IGNORE","INDEX")
Beispiel #30
0
    addlyr = ws+"\\"+tempmdb+"\\"+lyr
    MakeFeatureLayer_management(addlyr, lyrname)
    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 pointlyrlist: 
    outlyr = ws+"\\"+tempgdb+"\\"+str(lyr)+"_pt_1"
    print lyr +"_C is the layer I'm linear referencing now..."
    lyr = lyr+"_C"
    LocateFeaturesAlongRoutes_lr(lyr,"CMLRS","LRS_KEY",'0.5 feet', outlyr,"LRS_KEY POINT Cnty_Logmile", "FIRST", "DISTANCE", "ZERO", "FIELDS")
    MakeRouteEventLayer_lr("CMLRS","LRS_KEY",outlyr,"LRS_KEY POINT Cnty_Logmile",lyr+"_Events","#","ERROR_FIELD","ANGLE_FIELD","NORMAL","ANGLE","LEFT","POINT")
    print str(lyr) + " event table located as points "  + str(outlyr)
    
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
       
for lyr in linelyrlist_ST: 
    print lyr+"_C is the layer I'm linear referencing now..."
    outlyr = ws+"\\"+tempgdb+"\\"+str(lyr)+"_ln_1"
    lyr = lyr+"_C"