arcpy.PolygonToRaster Field input error

864
1
03-16-2017 05:39 AM
TroyMullins
New Contributor

script won't recognize input field for polygon to raster - error says : "Field 'x' does not exist within the table"

I join a text file to a polygon feature class.  I can list the fields no problem :

    for field in theDateFields:
         outputname = str(field.name)
         print outputname

have tried the field name and join file field name in python shell as a test - neither work.  For example, text file field name of "r19141231" or join file name of "rain1914.txt.r19140101"  -  neither work..  But again, they will both list in print statement above, but immediately following with tool does not recognize field (dayField): 

          arcpy.PolygonToRaster_conversion(yearGrid, dayField, outrast)

I can run toolbox Polygon To raster tool and select field and it runs, but script does not. I can even create model with tool loaded (it runs), then export to script, but script won't run - doesn't recognize field.  ?????

is there some formatting, parsing, etc I need to do for the field to be recognized in the script?

0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

The workaround is to save the joined files to a new file so that the join becomes permanent. This could be done by directing to an in_memory location I suppose, but it should clear up whether the fieldname alias or its joined name/alias is used

0 Kudos