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 try to build stacked label expression in ArcGis 10.3.1 with this expression:

[name3] + '\n'+ [results]

enter image description here

name3 and results are two columns in the attribute table. But I get this error:

typeerror coercing to unicode need string or buffer nonetype found

I read Building label expressions - Expression examples but didn't find any solution.

This is the attribute table:

enter image description here

enter image description here

share|improve this question
1  
Have you set to Python parser? – Martin 3 hours ago
    
you're mixing your parsers.. with a vb parser you need to use vbNewLine: [name3] & vbNewLine & [results] or change to python parser. – Michael Miles-Stimson 3 hours ago
    
Looks like you need to take a second look at what field types you are trying to merge. If not both are string, you might also need str(). – Martin 3 hours ago
    
I think this part of the error nonetype found hints at what may be astray. I think there is at least one <null> value in one or other field and when the Python parser gets to that it says that it cannot concatenate a nonetype (i.e. a <null>). – PolyGeo 2 hours ago
    
@PolyGeo I've been testing that, but I can't generate the same error when concatenating Nulls. I'm trying to figure how coercing to unicode need string comes into it here – Midavalo 2 hours ago
up vote 2 down vote accepted

A value in one (or both) of your fields is a number, and python is trying to add it due to the + symbol, or alternatively it could be a value that can't be handled in its current form. Either way you'll need to tell python that it's a string. It is currently trying to use the value as unicode and it needs a string.

Using the Python Parser you need to use:

"{}\n{}".format([name3], [results])

This will ensure that the values in your fields name3 and results are treated as string in the label, even if the fields contain numbers.

Alternatively, if you're using the VB Parser you could use:

[name3] & vbNewLine & [results]

Python Parser example:
enter image description here

VB Parser example:
enter image description here

share|improve this answer
str([name3]) + '\n'+ str([results])

Convert your attributes to strings before joining.

share|improve this answer
    
but both of the fields definite as string – newGIS 2 hours ago
1  
Did you try my answer? Did it work? – jbalk 2 hours ago
    
it worked but i get also 'NONE' values in the lables – newGIS 2 hours ago
    
To eliminate the None values, you could just update your table on all empty values with an empty string with 2 single quotes '' (not a double quote). They won't appear anymore. – RobinP 48 mins ago

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.