Playa

Create Multiple Rasters based on fields within a polygon that represent model results

Discussion created by Playa on Apr 16, 2014
Latest reply on Apr 18, 2014 by Playa
I'm still new to Python and have written the following python script based on the ArcGIS 10.2 help. I'm sure I'm missing some thing simple, but can't figure out why the script doesn't run, no errors are being returned. Any help will be appreciated.

I'm tyring to join a feature class to multiple tables found within the same file geodatabase one at a time using the field called "Quins" then converting the joined feature class to a raster based on the list of fields given, which represent different model results. The output is a raster based on the input table name and the field name within the list. The field names are identical in all the tables within the tables. The difference in the tables are return periods of my six models that I need to generate rasters from.

''
Created on Apr 16, 2014

@author: PeterW
'''
import arcpy
import os

# set the input workspace and model table

arcpy.env.workpsace = outputGDB = arcpy.GetParameterAsText(0)

# make feature layer and tableviews

arcpy.MakeFeatureLayer_management("Quins", "Quins_layer")
tables = arcpy.ListTables()

# Loop through each table, join it to the quins polygon and generate rasters based on model results stored in selected fields

try:
    for table in tables:
        arcpy.MakeTableView_management(table, "arcu")
        arcpy.AddJoin_management("Quins_layer", "Quins, "acru", "Quins", "KEEP_COMMON")
        acrufields = ["CSI","GF0","GF1","MIR","MPI","UKM"]
        for field in acrufields:
            valField = field
            outRaster = os.path.join(outputGDB, table + "_" + field)
            assignmentType = "MAXIMUM_AREA"
            cellSize = 500
            arcpy.PolygonToRaster_conversion("Quins_layer", outRaster, assignmentType, "", cellSize)
except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message


Regards

Peter Wilson

Outcomes