2

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:\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
  • After you create your Raster Layer, you should create the Raster Attribute Table, so you can join to it. You cannot join to a raster layer, only to a raster layer attribute table. resources.arcgis.com/en/help/main/10.1/index.html#//… – evv_gis Sep 8 '14 at 17:40
  • It is still not working with adding the rasterattribute table. Does anyone have another idea I really don’t know how to do this joins in iteration. – Nora Sep 9 '14 at 8:45
2

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

  • The environment settings are like in your picture, but it is not working… – Nora Sep 9 '14 at 7:32
  • 2
    It shouldn't be like in the picture, it should be unchecked (unqualified). If you work with different inputs with different field names though, your model will never really adapt the parameters to the new field names. Doing this with arcpy is much more robust. – GISGe Sep 9 '14 at 9:23
  • Ok, thanks a lot. I it is working on a way unchecked. But the problem is still that the raster attribute table is empty, so the second joint cannot work. See the new editing at the question; I build a model just with the first steps. – Nora Sep 9 '14 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.