Skip to main content
Question

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


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.

2 replies

takashi
Influencer
  • 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
  • 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.


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