TransWikia.com

ERROR 000728: Field Code does not exist in ModelBulider using iteration

Geographic Information Systems Asked by Nora on May 17, 2021

The first join in the model is working, but after this the names of the fields are changing in the name of the Shape and a number . Therefore get the ERROR 000728.

enter image description here

So I like to ask you if there is a way to work with this chanced field names by knowing which field need to be the join field. I like to make this question clearer with the following table.

enter image description here

So I know my Input field at the second join has to be the field “de021l_g_2”. I think the 2 is always there perhaps I can work with this, but how?

What can I do to make clear which field is the join field in the model which has to get a scripttool? Do you have an idea?
By the way is the “Feature Classes Iterator” the right one to loop through a folder with shapes?

Is it generally possible to do this join with the Modelbulider? I really can not find a solution for the problem. It just couldn’t find the field from the input table but it is there and it is the same fieldtype than the join field. I think I need to write this model with python to get a scripttool out of it. Is this the way I have to go? Or are there opportunities with the ModelBulider?

The first steps of the model, why is the raster attribute table empty???

enter image description here

It is working with this code now:

import arcpy
import os
from arcpy import env

env.overwriteOutput = True
env.workspace = r"C:JuPrurban_atlas_cities"
env.qualifiedFieldNames = False
#make a list with input cities as shapefiles.

fcList = arcpy.ListFeatureClasses()

for shpFile in fcList:
    shpFileName= os.path.splitext (shpFile) [0]
    print shpFileName # works
    # Process: Make Feature Layer
    arcpy.MakeFeatureLayer_management(env.workspace + "" + shpFile, "shpFile_ly")
    # join the city with the reclasstable
    jointable = r"C:JuPrreclass.dbf"
    arcpy.AddJoin_management("shpFile_ly", "CODE", jointable, "joinCODE", "KEEP_ALL")
    # Process: Copy Features
    outFeatureClass = shpFileName + "_join.shp"
    arcpy.CopyFeatures_management("shpFile_ly", outFeatureClass)
    # Process: Polygon to Raster
    outraster = shpFileName + "_join.img"
    cellSize = 200
    arcpy.PolygonToRaster_conversion(outFeatureClass, "CODE", outraster, "CELL_CENTER", "NONE", cellSize)
    # Process: Make Raster Layer
    arcpy.MakeRasterLayer_management(outraster, "outraster_ly")#works
    # Process: Add Join 
    arcpy.AddJoin_management("outraster_ly", "Value", jointable, "code", "KEEP_ALL")
# Process: Copy Raster
    outraster2 = shpFileName + "_join2.img"
    arcpy.CopyRaster_management("outraster_ly",outraster2) #works
# Process: Raster to Polygon
    outPolygons = shpFileName + "reclass.shp"
    arcpy.RasterToPolygon_conversion(outraster2, outPolygons, "NO_SIMPLIFY", "Value")#works

One Answer

When you create a join the field names get prefixed with the table name, for example:

Table1 joined to Table2
Table1 field OID becomes Table1.OID
Table2 field OID becomes Table2.OID

This is to distinguish fields from each of the tables that may have the same name. Shapefiles have a limited length of field names and as you will exceed that it's truncating with the name of table prefix followed by a number, this would not happen in a geodatabase until the field names became MUCH longer.

But there is hope, the environment setting Qualified Field name to UNQUALIFIED will allow you to work with the field names without the table names getting in the way. With this environment setting the copy features should retain the original field names.

Uncheck this box in the environment settings

Answered by Michael Stimson on May 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP