mardi 30 décembre 2014

Changing variable name in for loop


I am trying to run a simple python script that changes a feature to a polygon.


However, I want the outputted polygon to have the same name an the inputted feature. The code that I ran, outputs the name as "lyr", when I really want the name to be the input name. I used "lyr" as a variable name in for the for loop


This is what I have:



import arcpy
arcpy.env.workspace = "C:\Users\Daimon Nurse\Desktop\Grounds Project"
mxd = arcpy.mapping.MapDocument(r"C:\Users\Daimon Nurse\Desktop\Grounds Project\ZonesMAP.mxd")
Layerlist = arcpy.mapping.ListLayers(mxd)


for lyr in arcpy.mapping.ListLayers(mxd):
output = r'C:\Users\Daimon Nurse\Desktop\Grounds Project\DFMGROUNDS.gdb'
arcpy.FeatureToPolygon_management(lyr, output + '\lyr', '#', 'ATTRIBUTES', '#')
del lyr

del mxd




Aucun commentaire:

Enregistrer un commentaire