Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a data table with columns that includes city names (ex: San Jose) and state name abbreviations (ex: CA). Is there a way to define the state names as their full names (i.e., CA = California) and then combine city name and state name (ex: San Jose, California)?

I have approximately 120 records. So what I think I have to do is define each state as their full names (ex: NY = New York, FL = Florida, and so on) first. I guess I could create a new field and add these to it, and then combine this new field with full state names with city names? Does that make sense or is there another way to do it? Need to achieve this using Python.

Something like the following, but it doesn't seem right:

def stateNames(): # Add this pre-logic script in the code block
  CA = 'California'
  FL = 'Florida'
  GA = 'Georgia'
  HI = 'Hawaii'
  MN = 'Minnesota'
  NY = 'New York'
  # and so on...
return stateNames()

stateNames + !City_Name! # Add this in the box below pre-logic script
share|improve this question
up vote 13 down vote accepted

You could include the Python dictionary of state abbreviation:full-name pairs here

states = {
    'AK': 'Alaska',
    'AL': 'Alabama',
    'AR': 'Arkansas',
    # etc...

as the Codeblock in Field Calculator, and then use something like the following as the actual calculation:

!City! + ", " + states[!State!]

I should add that you could perform this calculation on either a new (text) field, or on the existing City field (or any other already-existing text field). I would recommend creating a new one, as you will otherwise not be able to easily revert to a field of only city names if you ever need them.

share|improve this answer
+1 Useful link! – Nathanus Nov 1 '11 at 21:21
@Noel Peterson, ah right! Forgot about dictionaries. Thanks for your help! It worked. – mapr Nov 1 '11 at 21:22
Nice concise answer, thanks for contributing. I suggest editing the answer and inserting the comment re: using a new field for reversibility. Doing so gives more visibility and builds an integrated, more complete, answer. – matt wilkie Nov 2 '11 at 18:54

Your Answer


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

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