[GIS] Removing null value in labels of ArcMap

arcgis-10.3arcgis-desktopexpressionlabelingpython-parser

Following this question:

Label expression in ArcGIS gives TypeError coercing to Unicode need string or buffer NoneType found?

I used this python expression in order to create a stacked label from two field: 'name3' and 'results':

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

enter image description here

enter image description here

the problem is that some of the labels contain "None" values that i don't want to represent in the map:

enter image description here

How can i remove the None values and still use the python phrase

I don't want to use VB phrae-i know that in VB the None values disappear from the map and still i prefer to use python.

Best Answer

With the use of label classes and filter your data with SQL queries you can label your features depending on their values in one or more fields.

So for your case, the two classes would be (SQL query)

"results" IS NOT NULL
"results" IS NULL

Then you can define different labels for them.

The same can also be done using conditional statements (IF results = None) in the Expression window in Advanced mode. However, this is usually more complicated in my experience.

See this page for help text: http://desktop.arcgis.com/en/arcmap/10.3/map/working-with-text/displaying-labels-using-label-classes-to-label-fea.htm

Related Question