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.

I have a table that contains a field with street names. Each street name ends with the street type. Fore example, Washington St, Happy Valley Rd, Redstone Dr. I need to extract the last part of the street name and have it populate a field called Street Type. I been trying to use the AttributeSplitter transformer but it only splits strings according to a delimiter (in this case it's a space), but this does not work. Any suggestion on using a different transformer or combination of transformers? Solutions need to be in FME as this task is part of a greater workflow.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Try the Regular Expressions.

It has been some time since I've used FME, but I know a while back they had a Regular Expressions Transformer (or the AttributeSplitter had a Regular Expressions option).

You should be able to use a regular expression to match some form of pattern.
For example, the address:

123 abc st, Sesame Street

could be matched by the regular expression:

"$[0-9]+\w[a-zA-Z]+([st|dr|av])[\wa-zA-Z]+"

Which indicates the pattern as,

  1. from the start of the string ($)
  2. there will be a sequence of digits : [0-9]+
  3. followed by a white space character (space, tab, etc) : \w
  4. followed by a string consisting of Upper and Lower case alpha characters: [a-zA-Z]+
  5. followed by the string of interest in the pattern: ([st|dr|av]) *NOTE
  6. followed by any number of white space and alpha characters: [\wa-zA-Z]+

NOTE The parenthesis () tag that part of the pattern to an attribute that you can use later on in your FME script.

I hope this gives you some pointers. I'll follow this question to help further if required.

share|improve this answer
    
I had a felling it was going to involve some funky expression. I also just found this. I'll give both a try. Thanks for chiming in. –  dchaboya Mar 27 '12 at 19:24
add comment

SubstringExtractor should work too

Category: Strings

Extracts a substring from the source attribute. The substring is taken from the range of characters specified. Character indexes start at 0 for the first character. A negative index is used to indicate the position relative to the end of the string (-1 is the last character, -2 the second last, and so on). The index can also be taken from the value of another attribute.

If the last index is greater than or equal to the length of the string then it is treated as if it were the end of the string. If the first index is greater than the last index then an empty string is placed into the result attribute.

Each of the index parameters may either be entered as a number, or can be taken from the value of a feature attribute by selecting the attribute name from the pull-down list.

Examples:

To trim off the first character only, use a start of 1 and an end of -1 To trim off the last character only, use a start of 0 and an end of -2 To extract the second and third characters in the string, use a start of 1 and an end of 2

http://docs.safe.com/fme/html/FME_Transformers/transformers/substringextractor.htm

share|improve this answer
add comment

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.