0

I currently am using a Python label expression to label parcels. I have 4 fields labeled. About 60% of my polygons label correctly, and the rest display the code in the expression, but still label. There is no difference between the polygons that DO label correctly and those that don't. There are no differences in the joined data either. Does anyone know why the label expression is being displayed in two ways on the same polygon data? I can't figure it out.

Python label error

  • 1
    welcome to GIS SE! Which system are you using, ArcGIS or QGIS? Can you edit your question to include the expression you're using to label your features (also, any code you're using)? – Steven Kay Aug 20 '18 at 17:37
  • as above, post your expression. do the labels adjust when you zoom in/out? – NULL.Dude Aug 20 '18 at 17:39
  • 1
    You need to find a workaround special characters like & . – FelixIP Aug 20 '18 at 18:58
3

As @FelixIP noted in a comment, it is likely the special character & that is causing you trouble. From the ArcMap help:

The ampersand (&) and angle bracket (<) are special characters and are not
valid in your text if formatting tags are used. Use the equivalent character
codes &amp; and &lt; instead.

http://desktop.arcgis.com/en/arcmap/10.3/map/working-with-text/using-text-formatting-tags-about-text-formatting-t.htm

You have not included your original label expression, so I can not suggest exact correction, but assuming your using ArcMap and the Python label parser, you would need to add .replace('&','&amp;') after any text field that may have & in the field's value. ex: [OwnerField].replace('&','&amp;') + '\n<CLR red=255'>' + ...

Or you could use field calculator on the original data to remove or replace the & in the data itself, but be warned the &amp; is only replaced with & automatically by ArcMap in labels when formatting tags (ex: <FNT ...> or <BOL>) are used. If no such formatting tags are used, the label would show on the map as LastName FirstName &amp; FirstName instead of the desired LastName FirstName & FirstName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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