1

In Arcmap I've created a complex label expression in the Display expression for my layer. I'd like to have that expression displayed when I convert the layer to .kmz file for display in Google Earth. I'm using the ESRI Layer TO KML conversion tool.

What happens in the popup right now is the display expression jammed, without the correct formatting, into the feature name box and also the feature description box, followed by the complete list of fields.

I've been looking at the HTML popup tab, but don't see any way to use the Display Expression I already have in that tab. Is it possible for this to happen? It looks like otherwise I'll have to write a XSL template.

EDIT: Thanks to @KHibma for the comment. What I've ended up doing is

  1. removing all of the fields from display in the shapefile properties in ArcMap before the export so they are not included in the kml popup
  2. Labeling the features in arcmap with one field so that field value is the "title" of the feature in the popup.
  3. adding HTML formatting tags to the Display Expression (which I was writing in Python). this expression appeared, formatted, in the blue box below the feature title.

I can't add a screenshot of the result right now, but will be able add it later.

This worked fine on a small scale, but when trying to export an entire parcel fabric for a county I would get a C++ runtime error.

One interesting thing I found was that, even before the export, if there was an error in the FindLabel function and it was not able to create a label, it would come back as empty. So I added a try/except statement within the function like:

def FindLabel([field1],[field2]):
    try:
        #code for function
    except:
        return "there was a problem creating this display"

which worked great. However, when I tried to import sys or traceback in the function and set the error handling message as the return in the except statement, it still returned blank (i.e. didn't return the text of the error handling message). In the end, I fixed all the problems with the expression, but still got the runtime error when making the big export.

  • As per the comment by @KHibma would you be able to include the simplest expression that demonstrates this, please? If it is VB specific then I personally would be happy with switching to Python as a workaround. – PolyGeo Sep 2 '14 at 20:10
  • 1
    Have you tried moving your label expression into the field calculator, and just making a "Label_Text" field with the labels pre-generated as text? – DPierce Jan 17 '15 at 17:51
  • It's been a while since I was working on this, but this would be a fine workaround if the label expression didn't include formatting, but I believe I had a few carriage returns or bolded words that would not work with your suggestion. – mr.adam Jan 20 '15 at 14:33
1

You seem to be encountering NIM099128:

Converting a Map or Layer to Key Markup Language (KML) when a layer has a formatted label expression; the expression displayed in the KML is not what is labeled.

The only workaround listed is to:

Format the labels through the standard label symbology, and not by using an expression.

The problem seems to have first been reported at ArcGIS 10.2.1, and appears to be assigned to a developer to address, but if you need a solution sooner rather than later, then it looks like you may need to develop your own workaround, because I do not think the above will meet your requirements.

  • Yes, it sounds like you're probably right. For right now I'm just adding html tags to the label expression, so there is a little bit of formatting. Pretty ugly work around so far... – mr.adam Sep 2 '14 at 1:03
  • 1
    I was the one at Esri working on that issue. The issue listed above is specific to using VB in the parser. If you switch to a Python parser it should also provide you with a workaround. (Unless I dont understand exactly whats in your expression) – KHibma Sep 2 '14 at 12:58

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.