rralbritton

Intersect Not Working

Discussion created by rralbritton on Nov 21, 2013
I'm getting an error message that my inputs are invalid and I can't figure out why.


#Convert buffer polygon to line
BufferLine = IntermediateFiles+"\\BufferLine_"+str(value)+".shp"
arcpy.FeatureToLine_management(outBuffer,BufferLine)

#Convert viewshed polygon to layer
ViewshedLayer = outName(OutPoly[:-8],"lyr")
arcpy.MakeFeatureLayer_management(OutPoly,ViewshedLayer)

#Select records with gridcode = 1
arcpy.SelectLayerByAttribute_management(ViewshedLayer,"NEW_SELECTION","GRIDCODE ="+str(1)+"") 

#Get count of the # of records selected in viewshed poly layer
VsLyrCount = int(arcpy.GetCount_management(ViewshedLayer).getOutput(0))
print str(value),"has",VsLyrCount,"records"
    
NoView = SummaryTables+"\\summary_Flr1_"+str(value)+".dbf"
YesView = SummaryTables+"\\summary_Flr1_"+str(value)+".dbf"
StatsField0 = [["GRIDCODE","SUM"]]
CaseField0 = ["ID","SPOT","OFFSETA",FloorField]               
StatsField1 = [["LENGTH","SUM"]]
CaseField1 = ["GRIDCODE","ID","SPOT","OFFSETA",FloorField]
VsArcLengths = ArcLengths+"\\ArcLength_Flr1_"+str(value)+".shp"
    
if VsLyrCount == 0: #no viewable areas exist
        arcpy.SetProgressorLabel("Calculating viewshed statistics for parcel "+str(value))
        arcpy.Statistics_analysis(ViewshedLayer,NoView, StatsField0,CaseField0)
        print arcpy.GetMessages()

        #Add field to summary table to hold viewshed value of 0
        #Add field to note which floor viewshed corresponds to
        arcpy.AddField_management(NoView, "FLR_RAN","SHORT")
        arcpy.AddField_management(NoView, "VIEW_"+Year,"DOUBLE")
        arcpy.CalculateField_management(NoView,"FLR_RAN",1)
        arcpy.CalculateField_management(NoView,"VIEW_"+Year,0)

else: #Calculate viewshed, in degrees, for selected records
        arcpy.SetProgressorLabel("Getting arc length")
        arcpy.Intersect_analysis(["BufferLine","ViewshedLayer"],VsArcLengths,"",10,"LINE")
        arcpy.AddField_management(VsArcLengths, "Length","DOUBLE")
        arcpy.CalculateField_management(VsArcLengths,"Length","!SHAPE.length@miles!","PYTHON_9.3")
        arcpy.Statistics_analysis(ViewshedLayer,YesView,StatsField1,CaseField1)
        print arcpy.GetMessages()

        #Add fields to output summary table
        arcpy.AddField_management(YesView,"FLR_RAN","SHORT")
        arcpy.AddField_management(YesView,"VIEW_"+Year,"DOUBLE")
        arcpy.CalculateField_management(YesView,"FLR_RAN",1)
        arcpy.CalculateField_management(YesView,"VIEW_"+Year,"((!SUM_LENGTH!/3.14)*180)","PYTHON_9.3")
        print arcpy.GetMessages()



Error

Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.1\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Users\Rachel\Desktop\OceanFront_ViewshedNEW.py", line 228, in <module>
    arcpy.Intersect_analysis(["BufferLine","ViewshedLayer"],VsArcLengths,"",10,"")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\analysis.py", line 312, in Intersect
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset BufferLine #;ViewshedLayer # does not exist or is not supported
Failed to execute (Intersect).

Outcomes