0

Currently Using ArcGIS Pro 2.3.2 and Python.

I am currently trying to label Road names, which are all uppercase in the database. I'm unable to edit the database but would like to Capitalize the road names and pick out one street to change the font and color for the road name.

I'm new to python and am having trouble working out how to combine these two expressions.

def FindLabel ( [road_name1] ):
  S = [road_name1]
  S = S.title()
  return S

def FindLabel ( [road_name1] ):
  if str([road_name1]) == 'LOOKOUT ROAD':
    return "<CLR red='0' blue='0' green='0'><FNT size = '22'>" + [road_name1] + "</FNT></CLR>"
  else:
    return "<CLR red='128' blue='128' green='128'><FNT size = '14'>" + [road_name1] + "</FNT></CLR>"
1

What you need to do is to create one function instead of two functions and put the S.title() inside the font change function like this:

def FindLabel ( [road_name1] ):
    S = [road_name1]
    if S == 'LOOKOUT ROAD':
        return "<CLR red='0' blue='0' green='0'><FNT size = '22'>" + S.title() + "</FNT></CLR>"
    else:
        return "<CLR red='128' blue='128' green='128'><FNT size = '14'>" + S.title() + "</FNT></CLR>"

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.