3

I have a data (school.shp) about schools. I have attribute values like:

TABIKA KG SENTOSA, TADIKA BANDAR SEMARIANG, KEMAS KG TABUAN, TABIKA KEMAS SANTUBONG, TADIKA KEMAS SERIAN

I need to label it like below::

TABIKA KG SENTOSA - TABIKA

TADIKA BANDAR SEMARIAN - TADIKA

KEMAS KG TABUAN - KEMAS

TABIKA KEMAS SANTUBONG - TABIKA KEMAS

TADIKA KEMAS SERIAN - TADIKA KEMAS

I just need to label TADIKA, TABIKA, KEMAS, TADIKA KEMAS, TABIKA KEMAS, no need to label the full name. Is there any VB or SQL query that can help me to settle this problem?

  • What is the rule for selecting which part of the attribute will become the label? TABIKA KG SENTOSA >> TABIKA, TADIKA BANDAR SEMARIAN >> TADIKA makes sense because you take the first word. TABIKA KEMAS SANTUBONG >> TABIKA KEMAS doesn't, because you take two first words. – Alex Tereshenkov Apr 8 '15 at 8:50
  • The rule is, no need to put the specific name of the school(for example the school name),just label either tadika,tabika,tabika kemas or tadika kemas only, im manage to label the TADIKA and TABIKA but im facing difficulty with the TABIKA KEMAS and TADIKA KEMAS, – abc Apr 8 '15 at 9:03
4

Since you have just a couple of cases to cover, you could use the Expression button in the Label Manager and then enter this code in the Label Expression dialog box (click Advanced check-box).

def FindLabel ([SCHOOL_NAME]):
  if 'TADIKA KEMAS SERIAN' in [SCHOOL_NAME]:
    labelText = 'TADIKA KEMAS'
  if 'TABIKA KEMAS SERIAN' in [SCHOOL_NAME]:
    labelText = 'TABIKA KEMAS'
  return labelText

You can add more cases to this expression (where [SCHOOL_NAME] is the field where you store the school name. And by the way, you don't need to use Maplex for that, standard labeling engine can handle label expressions, too (just in case you use Maplex only trying to handle this issue).

4

just as a complement to Alex Tereshenkov's answer, you need to find the expression that will work for all your school, and this can be done with the python expression below (see here for more details about building label expressions). First you test your complex cases, then you return the first word if the complex cases were not found.

def FindLabel ([SCHOOL_NAME]):
  if 'TADIKA KEMAS' in [SCHOOL_NAME]:
    labelText = 'TADIKA KEMAS'
  elif 'TABIKA KEMAS' in [SCHOOL_NAME]:
    labelText = 'TABIKA KEMAS'
  else:
    oldText = [SCHOOL_NAME]
    labelText = oldText.split(" ")[0]
  return labelText

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.