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.

Further to my earlier question about using different fonts on the same PC, I am wondering if label expressions would slow down drawing speed for a MXD?

Here is my label expression:

def FindLabel ( [GEONAME] ):
      import os
      if str(os.getenv("COMPUTERNAME")) == 'GIS-HP':
        return ("<FNT name='Adobe Fan Heiti Std B' size='8'>" + [GEONAME] + "</FNT>")
      else:
        return ("<FNT name='Arial' size='8'>" + [GEONAME] + "</FNT>")

This works like a charm and I haven't noticed anything yet, but I feel like adding this to all of my layers will dramatically slow down the drawing speed on my MXD. Drawing speed is one of the more important things for me as I share my MXD's with other users for them to do basic analysis. Usually I save a separate MXD, open it and change all the labels to something easy before sharing. If this doesn't slow down the drawing speed, that would be fantastic and save me some time down the line. Anyone have any ideas?

share|improve this question
2  
I don't believe this would slow down your drawing speeds. If drawing speeds are really important to you, you can also add definition queries to your layers, by going Layer > Properties > Definition Queries. Any data that does not need to show up on the map use the Definition Query to cancel it out for example (FEATURE <> 'LAKE'). Note that the layer will no longer pulled the data from the database, (assuming your on SDE) and will not show up in spatial queries etc. However you will see great improvements in drawing speeds. –  TForward Jul 17 '13 at 16:17

3 Answers 3

up vote 5 down vote accepted

Yes.

Label expressions slow drawing performance. In particular, avoid using label expression scripts to conditionally parse or format label strings or to concatenate the information in multiple fields into one label string when drawn. Instead, calculate a new field with exactly the information that is needed. The field can include formatting tags.

From ESRI Help, which also has a lot of other information about improving label drawing performance.

share|improve this answer
2  
From a common sense perspective, yeah, running code on every row is a lot slower than copying a string from a field on every row. I can't imagine a situation where a Python expression generating a string would ever run faster than a string copy in C. –  Jason Scheirer Jul 17 '13 at 18:23

You already know this solution, but it is worth mentioning:

I often make the mistake of zooming to the extent of 6000 point features, only to wait for them to label.

Label Scale Ranges will help tremendously in those situations. The labels are illegible at 50,000 scale anyway.

share|improve this answer

This will be much, much slower. Consider doing some pre-processing to avoid redundant work, put this in the codeblock instead:

import os

if str(os.getenv("COMPUTERNAME")) == 'GIS-HP':
  LABEL_TEXT = "<FNT name='Adobe Fan Heiti Std B' size='8'>{}</FNT>"
else:
  LABEL_TEXT = "<FNT name='Arial' size='8'>{}</FNT>"

def FindLabel( [GEONAME] ):
  return LABEL_TEXT.format( [GEONAME] )

Then it will only need to check the environment variable once per map render rather than per label. And you could build in a cache as well if you have a lot of repeated values:

import os
if str(os.getenv("COMPUTERNAME")) == 'GIS-HP':
  LABEL_TEXT = "<FNT name='Adobe Fan Heiti Std B' size='8'>{}</FNT>"
else:
  LABEL_TEXT = "<FNT name='Arial' size='8'>{}</FNT>"

VALUE_CACHE = {}

def FindLabel( [GEONAME] ):
  if [GEONAME] not in VALUE_CACHE:
      VALUE_CACHE[ [GEONAME] ] = LABEL_TEXT.format( [GEONAME] )
  return VALUE_CACHE[ [GEONAME] ]
share|improve this answer

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.