Skip to main content
Question

Comparing field string length and choosing one based on a test.

  • August 13, 2018
  • 2 replies
  • 99 views

Hello All,

Problem:

I have a csv that has 2 sets of UTM coordinates (Eastings,Northings) for each location. I would like to compare the length of the values and choose the set that has the most precision (most number of decimal places) and then write that pair to new columns.

I am using the StringLengthCalculator to create and populate a field for each Easting and Northing.

Eg: 1EastingLen, 1NorthingLen, 2EastingLen, 2NorthingLen.

I'm getting stuck on how to use a TestFilter to write one of the pairs based on some logic.

If I were to pseudo code what I want, it would sound like this:

For all records in csv:

If 1EastingLen >= 10, then write 1Easting to new Easting Colum AND write 1Northing to new Northing column.

Else write 2Easting to new Easting etc....

All help is appreciated.

Thanks.

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.

2 replies

takashi
Celebrity
  • 7843 replies
  • August 14, 2018

Hi @ogc_ryan,

if you would filter the features with a TestFilter, you could create the new Easting/Northing attributes with AttributeCreators (or AttributeManagers) connected to each output port.

Alternatively, you could create the new Easting/Northing attributes directly using Conditional Value setting in an AttributeCreator (or an AttributeManager), without using the TestFilter.


  • Author
  • 4 replies
  • August 14, 2018

Thanks Takashi.

The second option is what I was envisioning, and it worked well.

The solution:

  1. Use the StringLengthCalculator to create a new attribute for each easting and northing.
  2. Use the AttributeCreator to create new easting and northing fields.
  3. Use conditional arguments to choose the best value to apply to the new fields.