Skip to main content

Hello,

I have a field called SPECIES that could contain surveyed tree values such as E,AS,TA within each record; or perhaps the record could contain just AS or maybe JP,BS, etc. What I would like to do is categorize those values in that record into a new field value such as 'Stocked to Hardwood', 'Stocked to Softwood' etc. (see image). However, I'm having problems as what I would like to categorize as 'Stocked to Hardwood' (e.g. record with AS,TA) is getting flagged as 'Stocked to Softwood and Hardwood'. Is there any way I can use existing operators to categorize a value such as AS,TA to be 'Stocked to Hardwood' or do I need to break this SPECIES field up and extract each tree species separately and work with those?

Thanks.

First, I do not think you need the "NOT IN" clauses as the "Else If" excludes those anyway.

Then a question: With "I have a field called SPECIES that could contain surveyed tree values such as E,AS,TA within each record", do you mean SPECIES can be E or AS or TA, or do you mean it can contain "E,AS,TA". In the latter case the IN statement will not work.

Finally: the test clause is by default case sensitive. Are the SPECIES values always uppercase?


First, I do not think you need the "NOT IN" clauses as the "Else If" excludes those anyway.

Then a question: With "I have a field called SPECIES that could contain surveyed tree values such as E,AS,TA within each record", do you mean SPECIES can be E or AS or TA, or do you mean it can contain "E,AS,TA". In the latter case the IN statement will not work.

Finally: the test clause is by default case sensitive. Are the SPECIES values always uppercase?

Hi...the SPECIES can contain "E,AS,TA". The values in this field will vary, so "AS" on its own is also possible, or perhaps "JP,BF,AS", etc. The SPECIES values will always be uppercase and separated by a comma if more than one species was surveyed.

 

 


I managed to figure this out using StringSearcher, Aggregator and FeatureJoiner (see images).


@aviveiro

If you use the regexps you use in the string searchers in a conditional attribute creator you would have only 1 transformer

Prevents to route the data trough 3 identical streams, and you then don't need to join the result attribute back to the features.

cleaner, more efficient and faster.


I managed to figure this out using StringSearcher, Aggregator and FeatureJoiner (see images).

0684Q00000ArJlLQAV.jpg

0684Q00000ArJzEQAV.jpg

0684Q00000ArK2yQAF.jpg

Good solution.

 

Just be aware that the regular expression "AS|BA|TA|WB|E|BT" matches not only  "E" (hardwood) but "EC" (softwood).

 

A quick workaround is, add leading and trailing commas to both the regex and the "Search In" value. The StringSearcher parameters dialog would look like this.

 

Note: If there could be spaces between a comma and the following species in the SPECIES value, remove the spaces beforehand. [Addition] Or, use this regex to find matched species even if there were spaces after/before the comma.

 

,\s*(AS|BA|TA|WB|E|BT)\s*,

 

0684Q00000ArM5XQAV.png