Skip to main content
Question

Assign closest category number to a value

  • June 11, 2020
  • 1 reply
  • 4 views

katt
Supporter
Forum|alt.badge.img+12
  • Supporter

Hello, I have three records: 1.07, 2.34 and 4.81 and I have 5 different categories:

categoryvalueA0.65B2.55C3.85D4.75E7.95 I want to assign a category to each of my three records. The category assigned should be the one with the value closest to the record.

For record 1.07 it should be category A, for 2.34 it should be B and for 4.81 it should be D. How can the assignment be done automatically? What transformer to use? thx.

1 reply

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • June 11, 2020

Hi @katt,

The easiest method would be to use the AttributeRangeMapper, and set the ranges to the midpoints between the category values.

If you are getting your categories from an external source (ie. Excel), there is a slightly more complex method that will also give you good results. Use VertexCreators to create points from records and categories, where you set X to the value and Y to 0. Next, use the NeighborFinder transformer with the records sent to Base and the categories sent to Candidates. Enable Merge Attribute in the NeighborFinder to transfer the category to the record.

 


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