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.
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.
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???
It is working with this code now:
import arcpy
import os
from arcpy import env
env.overwriteOutput = True
env.workspace = r"C:\Ju\Pr\urban_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:\Ju\Pr\reclass.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