Skip to main content

Hello,

I want to create a unique numeric ID in a new attribute field from a two-letters string attribute, this way:

feature - ID

AA - 1

AB - 2

AC - 3

BA - 1

BB - 2

CA - 1

CB - 2

 

CC - 3

 

CD - 4

etc...

 

I guess I need to count how many times a letter is listed and then create IDS for every count and repeat but I don't know how to do this.

 

Many thanks,

 

Max

Hi @max_d Is the ID based only on the 2nd character in the string?


As long as it is a 2 character identifier and it is the first character that resets the ID Counter every time it changes:

  1. Input to Sorter: Sort by "Feature" Ascending
  2. Then use SubstringExtractor or AttributeCreator to extract the First Letter to a new Attribute, let's call it "FirstChar"
  3. The use Counter, set the Counter Name to @Value(FirstChar)

 


Hi @max_d Is the ID based only on the 2nd character in the string?

HiDanatsafe, indeed, the ID is based on the first one character in the string . A,B,C,D, etc.


As long as it is a 2 character identifier and it is the first character that resets the ID Counter every time it changes:

  1. Input to Sorter: Sort by "Feature" Ascending
  2. Then use SubstringExtractor or AttributeCreator to extract the First Letter to a new Attribute, let's call it "FirstChar"
  3. The use Counter, set the Counter Name to @Value(FirstChar)

 

nice idea!


Thank you Bwn, it's working really well!


Reply