0

I'm using ArcGIS Pro 3.0. I have a Streets feature class that includes the ordinal for numeric streets in the street name field. For example, for "13th Street", the name field is "13th" instead of "13". I want to label these numbered streets with the ordinal in superscript. So instead of 13TH or 13th, I want 13th. Like this: enter image description here

Is there a way to make these ordinals superscript in an Arcade labeling expression? I am aware of the Arcade superscript labeling syntax '<SUP>'+$feature.ST_NAME+'</SUP>' and that would work great if the ordinals were pulled into a separate field. Am I missing something obvious?

The street name field also includes non-numerical street names like Main, Hwy 160, and CR 240.

1

1 Answer 1

-1

With the help of the oh-so-handy ChatGPT, I used the following Python code to parse ordinals to a new field.

import re

def parse_ordinal(street_name):
    # Use a regular expression to search for ordinal patterns in the street name
    match = re.search(r'\b(\d+)(st|nd|rd|th)\b', street_name)
    if match:
        # Return the ordinal found in the street name
        return match.group(1) + match.group(2)
    else:
        # Return an empty string if no ordinal is found
        return ''

# Example usage
street_name = "123rd street"
print(parse_ordinal(street_name)) # Output: "123rd"

If you want to just return the ordinal, delete the match.group(1) + from the code. From there, you can work with label classes to create "Numbered" and "Named" street classes based on the presence of an ordinal in the parse_ordinal result.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.