Skip to main content

Hello, I have a problem with some transformers. I have two shapefile with TERYT number, one shapefile contains TERYT number for communes - e.g. 0201032 and second one TERYT number for country - e.g. 0201. As You see four first characters are the same. I have to trim from right side communes TERYT number to look like as country TERYT number. Secondly, I have to find this trimmed number in a list to say which communes are in the country.

 

 

I used AttributeCreator to copy TERYT number, SubstringExtractor to trim commune TERYT number. Now, I would like to use TESTER to check if my new number is in the list and if it passed I would like to create new attriute with contains the name of country. Everything failed on TESTER. Could anyone help me?

First thing is to add an Inspector after the Tester transformer to see why it fails.

My guess is that one of the attributes will be converted to a numeric value (201 instead of 0201).

I assume you used index 0 to 3 in the SubstringExtractor (that will be the first 4 characters).

Besides that this should work and you are on the right track.

To merge the country name on the communes you will need the FeatureMerger transformer (communes as Requestor, country as Supplier).


You will only want to use the SubstringExtractor on the shapefile containing the communes. From there, you can use a FeatureMerger feeding the communes into the Requestor port, and country into the Supplier port. You will need to specify the attributes that contain the common TERYT number. The features from the merged port will be communes, with attributes of the matching country.


One of the reasons you could be failing at the Tester is if the two attributes you are comparing there don't match.

 

EX- _substring (1) vs jpt_kod_je(1) might not match but _substring(2) and jpt_kod_je(1) do.

 

The Tester won't look at the TERYT attributes as a list to see if the one you're comparing against is in there. You could create a list of the different country values (ListBuilder), and compare against the communes values that way. The FeatureMerger like @cartoscro and @erik_jan is also the way to go.


The Transformer FeatureMerger helps! Thank you so much!

 


First thing is to add an Inspector after the Tester transformer to see why it fails.

My guess is that one of the attributes will be converted to a numeric value (201 instead of 0201).

I assume you used index 0 to 3 in the SubstringExtractor (that will be the first 4 characters).

Besides that this should work and you are on the right track.

To merge the country name on the communes you will need the FeatureMerger transformer (communes as Requestor, country as Supplier).

Two attributes is text type - all has 0 in front of them.

 

 


Reply