How do I dynamically define an output feature class using variables

3902
0
01-08-2015 09:15 AM
LauraBlackburn
New Contributor III

I am creating code to loop through feature classes in a folder and run the fishnet process.  I am trying to define the output feature class so that it is a combination of the input feature class and the scale used.  Here's what I have so far....any help is greatly appreciated as this is all new to me.

# Import arcpy module

import arcpy, os, sys, traceback

# Set the necessary product code

import arceditor

import arcinfo

# set workspace path for block location

aDataPath = 'F:\\Workspace\\Sandy\\GM_costAnalysis\\analysis2\\'

arcpy.env.workspace = 'F:\\Workspace\\Sandy\\GM_costAnalysis\\analysis2\\'

# Set datapath for grid files

bDataPath = 'F:\\Workspace\\Sandy\\GM_costAnalysis\\analysis2\\6K\\'

# Set Geoprocessing environments

arcpy.env.snapRaster = ""

# Create a list of cell sizes

scaleList = [6000, 4000, 3000, 2000, 1000, 500]

# Create a list of searching radii

radiusList = ["3000 Meters", "2000 Meters", "1500 Meters", "1000 Meters", "500 Meters"]

# Step 1 - loop through each block and do the following processes at all grid scales

try:

     # Create List of feature classes starting with 'B' - all the block layers

    fc_list = arcpy.ListFeatureClasses("B*")

    for fc in fc_list:

        # Process: Create Fishnet

        # Create a describe object from the feature class

        desc = arcpy.Describe(fc)

        for scale in scaleList:

            # Define Fishnet Output Name

            Output_Grid_Name =bDataPath + scale + fc

             tempEnvironment0 = arcpy.env.extent

            arcpy.env.extent = desc.extent.XMin, desc.extent.XMax, desc.extent.YMin, desc.extent.YMax

            arcpy.CreateFishnet_management(Output_Grid_Name, desc.extent.XMin desc.extent.YMin, desc.extent.Xmin desc.extentXMax, scale, scale, "0", "0", desc.extent.XMax desc.extent.YMax, "LABELS", fc, "POLYGON")

            arcpy.env.extent = tempEnvironment0

except:

0 Kudos
0 Replies