Skip to main content
Solved

How to clean up string field of elevation values?


I am converting an excel spreadsheet to an esri geodatabase feature class of points. Working well so far, except for one field of elevation values. There was no standard of input and the values are varied. For example:

  • 75 feet
  • 75 ft.
  • 75 ft
  • 75f
  • 75 MSL
  • 25 m / 75 f

If it weren't for the last example, which occurs too often to waste time updating manually, I'd just use a string replacer to extract just the numbers, but in that last example, I'd end up with 2575 instead of just 75. I'm guess that first I need to remove everything before and including the '/', and then can use a stringreplacer with regular expression '[0-9]+' . Also, I've gotten another spreadsheet of data in which "##m" occurs. Those rows would need to be converted to feet. Hoping this is solvable with transformers, as the data is not to be edited.

Best answer by takashi

If your posted patterns cover all possible patterns to represent an elevation, the StringSearcher with these parameters extracts the numbers and the unit from those representations and save them into _sub{} list ("sub{0}.part" stores numbers, and "sub{1}.part" stores units).

  • Contains Regular Expression: (\\d+)\\s*(\\D+)$
  • Subexpression Matches List Name: _sub

You can then determine if the unit is 'm' and convert the value if necessary.

View original
Did this help you find an answer to your question?

3 replies

takashi
Evangelist
  • Best Answer
  • June 8, 2018

If your posted patterns cover all possible patterns to represent an elevation, the StringSearcher with these parameters extracts the numbers and the unit from those representations and save them into _sub{} list ("sub{0}.part" stores numbers, and "sub{1}.part" stores units).

  • Contains Regular Expression: (\\d+)\\s*(\\D+)$
  • Subexpression Matches List Name: _sub

You can then determine if the unit is 'm' and convert the value if necessary.


redgeographics
Celebrity
Forum|alt.badge.img+50
takashi wrote:

If your posted patterns cover all possible patterns to represent an elevation, the StringSearcher with these parameters extracts the numbers and the unit from those representations and save them into _sub{} list ("sub{0}.part" stores numbers, and "sub{1}.part" stores units).

  • Contains Regular Expression: (\\d+)\\s*(\\D+)$
  • Subexpression Matches List Name: _sub

You can then determine if the unit is 'm' and convert the value if necessary.

If I understand the regex correctly it searches for the last combination of a couple of digits and some text in the string, am I right?

 

 


takashi
Evangelist
  • June 11, 2018
redgeographics wrote:
If I understand the regex correctly it searches for the last combination of a couple of digits and some text in the string, am I right?

 

 

Yes, you are right. The regex would match only the last pair of digits (only numbers) and text (not containing numbers at all), if there were two or more pairs in the source string.

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings