I am trying change the value of a row for a field whose type is "short" in arcmap using a python script.

with arcpy.da.UpdateCursor(FILENAME, FIELD) as cursor:

    for row in cursor:
        row = 'Center'

with this i receive the error "RuntimeError: The value type is incompatible with the field type."

I know I am giving a string type to a "short" type field. Is there a way around this? There are pre-set values in this field. Do I need to run some other kind of code to create a list of possible values for this field, then select the value based on some kind of list interaction eg row = fieldlist[1]

Please ask me to clarify anything, but this is everything that seems relevant to me at this point.

  • You can't change the row object directly. You need to change the field on the row. Short is a number not a string.
    – Nathan W
    Aug 6, 2013 at 1:44
  • What do you mean by pre-set values in this field?
    – Nathan W
    Aug 6, 2013 at 1:48
  • So if i do this manually in arcmap, when i edit this fc, the field has a dropdown menu of values i can choose.
    – TheLastGIS
    Aug 6, 2013 at 1:49
  • Sure. So your goal is to get the number value for 'Center'? Correct?
    – Nathan W
    Aug 6, 2013 at 1:51
  • 1
    What are your variables FILENAME and FIELD set to? Please edit your question to include that critical information. Try to make clear what your data and field types are.
    – PolyGeo
    Aug 6, 2013 at 2:05

1 Answer 1


Sounds like you have a coded value attribute domain for that field.

Something like the following might give you some ideas.

import arcpy

fieldname='test' #This is a short integer field with a coded value attribute domain
arcpy.env.workspace = fgdb

#Get a reference to the Field object so we can    
#find out what attribute domain it uses

#Find out what the coded values are and make a look up dict for them.
domains = arcpy.da.ListDomains(fgdb)
for domain in domains:
    if domain.name == field.domain:
        #assume domain.domainType == 'CodedValue'
        coded_values = domain.codedValues
        #Reverse the coded_values key/values so we can query by the coded value description

#Set field
with arcpy.da.UpdateCursor(featclass, fieldname) as cursor:
    for row in cursor:
        row[0] = lookup_values['Centre']
  • Thanks Luke this looks really helpful. I've been looking through the ESRI docs to find these types of functions to build a solution like this.
    – TheLastGIS
    Aug 6, 2013 at 3:15
  • @JackHansen - to find out if you actually do have a coded value domain, rightclick on the featureclass in ArcCatalog (or the layer in ArcMap TOC), select properties->fields tab and click on the field to see its properties. If it has a domain, you should see something like domain (or coded value domain) some_domain_name in the field properties.
    – user2856
    Aug 6, 2013 at 3:21
  • It reads under 'Field details' > 'Coded value domain' > 'VerticalAlignment'. 'VerticalAlignment' being the field I am interested in. So I can make the assumption that this is a coded value domain.
    – TheLastGIS
    Aug 6, 2013 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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