I am rather new to Python but I am trying to define a function that will take the output of one of my prior functions (5 buffered stream files) and intersect each unique streamBuffer file with an LULC shapefile. So, I want to create 5 unique intersection shapefiles.
My problem comes when trying to figure out how to input this into a variable that will fit inside the arcpy Intersection_analysis tool.
My code currently looks like this:
def identHabitat(self):
'''Creates a polygon shapefile by intersecting the shapefiles
resulting from calcBuffer, identCover, and identDev. The result
shows areas within a specific watershed where habitat suitable for
the desired species could be found.'''
workspace = arcpy.env.workspace = (sys.argv[7])
arcpy.env.overwriteOutput = True
buffList = arcpy.ListFeatureClasses("*buff_{0}*".format(self.abbrv))
unionFile = arcpy.ListFeatureClasses("*{0}_LULC*".format(self.abbrv))
inFeatures = [unionFile]
for fc in buffList:
outFeatures = "{0}_Habitat".format(self.abbrv)
inFeatures.extend(fc)
try:
intLayers = arcpy.Intersect_analysis(inFeatures, outFeatures)
message = "Habitat successfully identified!"
except:
message = "Habitat could not be identified, please try again."
return message
I put a breakpoint on the line defining the workspace and watched the "inFeatures" variable. This was its value:
Obviously, this is not what I'm trying to do. I want my variable to have a value of: [[u'nopa_LULC.shp'], fc]
And again, I'm new to Python so I'm sure some of this is not the best coding you've ever seen.