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.

I am trying to build a field calculator expression to merge two columns into one. I am looking for the word that makes it a range.

Example: I have 2 columns in elevation, From and To. I want to make them like "4100 - 4200" where I add the hyphen. How do I do that ?

table showing data being worked with

share|improve this question
    
Hope you don't mind, I took the liberty of reducing the size of the image while retaining enough info to see the data being working with. I also took the red out as it was too glaring, and overpowered the question itself. Now it should be easier to skip from question to answer without (much) scrolling. –  matt wilkie Oct 11 '11 at 19:29
    
No problem. I didn't realized that, Matt. Thanks for letting me know and I will remember this. –  PROBERT Oct 11 '11 at 20:40

1 Answer 1

up vote 12 down vote accepted

You will want to concatenate the two fields together.

To do this in ArcMap you can use the VB Script function "&". So using your example, the calculation would be

[FROM] & "-" & [TO]

You could also use Python syntax, in which case your code would be:

str(!FROM!) + "-" + str(!TO!)

With Python you want to be sure to enclose the fields in the string function -- str()--, so that Python knows you are trying to concatenate two strings together, and not do a mathematical computation.

share|improve this answer
    
Thanks, Ryan. I figured it out. –  PROBERT Oct 11 '11 at 16:35
    
just for fun, you could also use the format string python operator: "%s - %s" % (str(!FROM!), str(!TO!)), which in this case is more complicated than the above, but is easier if you want to more extended concatenations, e.g. "Min %s - to - %s Max" % (str(!FROM!), str(!TO!)) –  matt wilkie Oct 11 '11 at 22:56

Your Answer

 
discard

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.