Skip to main content
Solved

How to clean up string field of elevation values?

  • June 8, 2018
  • 3 replies
  • 22 views

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Celebrity
  • 7843 replies
  • 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+60
  • Celebrity
  • 3703 replies
  • June 11, 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.

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
Celebrity
  • 7843 replies
  • June 11, 2018
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.