def execute(self, parameters, messages):
        # Access the parameters: (Returns values as stringtypes)
        infc = parameters[0].valueAsText
        field_name = parameters[1].valueAsText
        field_value = int(parameters[2].valueAsText)

        # -----------------------------------------------------------------
        # Frequently Used Variables
        code_directory = 'E:\\redistricting_data\code'
        infc_dir = os.path.split(arcpy.Describe(infc).catalogPath)[0]
        infc_name = arcpy.Describe(infc).file
        write_file_name = 'temp_output.txt'
        # -----------------------------------------------------------------

        # define the workspace using the path name of the input feature class
        env.workspace = infc_dir

        # Add Field to the Feature Class
        try:
            arcpy.management.AddField(infc_name, field_name, "LONG")
        except arcpy.ExecuteError:
            print arcpy.getMessages(2)

        # Populate the Field
        arcpy.management.CalculateField(infc_name, field_name, field_value)
    def execute(self, parameters, messages):
        # Access the parameters: (Returns values as stringtypes)
        infc = parameters[0].valueAsText
        field_name = parameters[1].valueAsText
        field_value = int(parameters[2].valueAsText)

        # -----------------------------------------------------------------
        # Frequently Used Variables
        code_directory = 'E:\\redistricting_data\code'
        infc_directory = os.path.split(arcpy.Describe(infc).catalogPath)[0]
        infc_name = arcpy.Describe(infc).file
        write_file_name = 'temp_output.txt'
        # -----------------------------------------------------------------

        # define the workspace using the path name of the input feature class
        env.workspace = infc_directory

        # Add Field to the Feature Class
        try:
            arcpy.management.AddField(infc_name, field_name, "LONG")
        except arcpy.ExecuteError:
            print(arcpy.getMessages(2))

        # Populate the Field
        arcpy.management.CalculateField(infc_name, field_name, field_value)
Exemple #3
0
##        tWorkspace = CreateTempWorkspace(outWorkspace)
##else:
##    tWorkspace = CreateTempWorkspace(outWorkspace)
##arcpy.Workspace = outWorkspace
##tmpRaster = tWorkspace + os.sep + 'tmpRast'

# Rescale inputs if requested.  Rescaled inputs will be stored in outRescale.
if rescale == 'true':
    cost2 = fl.Rescale(cost1, outRaster, Min, Max)
    cost1 = cost2

# Invert any inputs with this option selected
if invertCost1 == 'true':
    cost2 = fl.InvertRaster(cost1, outRaster)

arcpy.AddMessage("Outraster is: " + outRaster)
# Add Cost Raster to Display

cost2.save(outRaster)

try:
    arcpy.SetParameterAsText(5, outRaster)
    params = arcpy.GetParameterInfo()
except:
    arcpy.getMessages(2)

# Clean up temporary workspace
# CleanFiles(tWorkspace)
arcpy.Delete_management("in_memory")
del arcpy
##arcpy.Workspace = outWorkspace
##tmpRaster = tWorkspace + os.sep + 'tmpRast'


# Rescale inputs if requested.  Rescaled inputs will be stored in outRescale.
if rescale == 'true':
    cost2 = Rescale(cost1,outRaster,Min,Max)
    cost1 = cost2


# Invert any inputs with this option selected
if invertCost1 == 'true':
    cost2 = HabToCost(cost1,outRaster)
    
arcpy.AddMessage("Outraster is: " + outRaster)
# Add Cost Raster to Display

cost2 = outRaster

try:
    arcpy.SetParameterAsText(5, outRaster)
    params = arcpy.GetParameterInfo()
except:
    arcpy.getMessages(2)

# Clean up temporary workspace
# CleanFiles(tWorkspace)
arcpy.Delete_management("in_memory")
del arcpy