Select to view content in your preferred language

Lable BASED on a features Color

938
3
04-02-2014 12:52 PM
RobertBorchert
Honored Contributor
I am looking for a script to use in a features label would label it with that features color.

In RGB
Tags (2)
0 Kudos
3 Replies
JoshuaChisholm
Frequent Contributor
Cool idea Robert!

Try this:
def FindLabel ( [Label],,,):
  s='<CLR red="'+str()+'" green="'+str()+'" blue="'+str()+'">' #should return something like: <CLR red="255" green="00" blue="00'">
  s+=[Lable]
  s+="</CLR>"
  return s
0 Kudos
RobertBorchert
Honored Contributor
I know Python is the next logical step in my GIS progession.  But right now I am pretty ignorant.

I tried pasting the code into the the label expression (maplex)  it said it was a valid code no features found could not verify expression.  I don't have it set up with any definition queries and all features are showing.

In the ArcMap Drawing Errors window that popped up it then says

General Function Failure.
Too few parameters.  Expected 3

Any suggestions on what I am doing wrong.

Or should I be using field calculator to fill a field with this?


Cool idea Robert!

Try this:
def FindLabel ( [Label],,,):
  s='<CLR red="'+str()+'" green="'+str()+'" blue="'+str()+'">' #should return something like: <CLR red="255" green="00" blue="00'">
  s+=[Lable]
  s+="</CLR>"
  return s
0 Kudos
JoshuaChisholm
Frequent Contributor
Python is a great language, but this small script is a little complicated. We're trying to create a sting output with tags and quotes, so the python code gets pretty messy. Usually it's a little easy to follow.

Let's start with the basics.

  1. What does your data look like?

  2. Which field are trying to label?

  3. Which field(s) hold the RGB values? and how are they formatted?

0 Kudos