Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

hi guys i m doing a script in Arcgis i m new to this, i have to append some field from a table to another, i did this script in python but i have a problem when it want make the Mapping field with a field of type shape shape i mean = point, line, polygon ..

the error that i get is this one:

FieldMap: Error in adding input field to field map Failed to execute (script).

# import system modules
import arcpy, os
from arcpy import env

# get parameters
tabellaInput = arcpy.GetParameterAsText(0)

tabellaOutput = arcpy.GetParameterAsText(1)
# Set local variables
fieldMappings = arcpy.FieldMappings()
# add the table to field mapping
fieldMappings.addTable(tabellaOutput)


fieldnames = [f.name for f in arcpy.ListFields(tabellaInput)]
fieldnamesOut = [f.name for f in arcpy.ListFields(tabellaOutput)]

for elem in fieldnames:
arcpy.AddMessage(str(elem));



if str(elem) not in fieldnamesOut:
    continue

#creat a field map for each field.
fldMap = arcpy.FieldMap()
fldMap.addInputField(tabellaInput,elem) # deve aggiugere questo field

# Set name of new output field
namefield = fldMap.outputField
namefield.name = elem
fldMap.outputField = namefield
# Add output field to field mappings object
fieldMappings.addFieldMap(fldMap)



schemaType = "NO_TEST"
subtype = ""

try:


# Process: Append the feature classes into   feature class
arcpy.Append_management(tabellaInput, tabellaOutput, schemaType, fieldMappings, subtype)

except:
# If an error occurred while running a tool print the messages
print arcpy.GetMessages()

it dose stop inside the

for....

when come a field of type shape

infact if i add inside the

 for 

the following line of code:

 if elem == 'Shape':
    continue

it works good .. this is pretty strange. Another things is this: I have more fields in the input table then the target table so why in the target i don't see all the fields of the input table? i should do a merge e not the append??

share|improve this question
add comment

2 Answers

There is a very similar problem described and resolved in the ArcGIS Discussion Forums.

The solution seems to have been to use Add and Calculate Field to make sure that the input fields on all input tables are absolutely identical.

share|improve this answer
    
fields are equal thx for reply i trying –  user9143 Jul 27 '12 at 7:45
add comment

It's a feature not a bug. Seems that you do not need to add the SHAPE field to mapping, it will always be included and remain in the feature class. You can't seem to rename it either.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.