Question

Creating columns based on values contain in the row - grouping


Hello,

I am currently working with gbXML file in FME. I am trying to display the points, out of the coordinates that I have.

In the column Coordinate_xml_id last character refers to axis. 1-x, 2-y, 3-z.

What I would like to do is to create separate columns for x, y, z Coordinates - so having all the x coordinates with Coordinate_xml_id with 1 at the end in one column, all the coordinates with coordinate_xml_id with 2 at the end in another column, etc.

Any help would be much appreciated!


4 replies

Badge +7

Hi @aleksandragabry,

I don't know if this will get you all the way there, but the AttributeCreator has the ability to define new attributes based on attribute values.

 

You could create new attributes based on the values of the 'Coordinate_xml_id' and assign them the value of 'Coordinate'.

Hope this helps!

 

Nathan
Userlevel 3
Badge +13

You can also use an Aggregator set to group-by coordinate_parent_xml_id and in the process create a list with the three coordinates per parent id. Then use a VertexCreator to pull the values from the list. See demo attached. I suspect that @NathanAtSafe's option might be a little quicker but this is another optiondemo.fmw

Userlevel 2
Badge +17

Hi @aleksandragabry, looks like each parent "CartesianPoint" has always three "Coordinate" elements as its children. If my observation was correct, you could set "CartesianPoint" to the Element to Match parameter in the XML reader to read "CartesianPoint" elements as features and store the coordinate values as a list attribute "Coordinate{}". You can then rename the list elements to x, y, z with the AttributeRenamer. An advantage of this way is that it could be more efficient than reading each "Coordinate" element as individual feature, since the number of features to be created could be reduced a lot.

Hi @aleksandragabry, looks like each parent "CartesianPoint" has always three "Coordinate" elements as its children. If my observation was correct, you could set "CartesianPoint" to the Element to Match parameter in the XML reader to read "CartesianPoint" elements as features and store the coordinate values as a list attribute "Coordinate{}". You can then rename the list elements to x, y, z with the AttributeRenamer. An advantage of this way is that it could be more efficient than reading each "Coordinate" element as individual feature, since the number of features to be created could be reduced a lot.

 

Thanks! I used it and received exactly what I wanted.

 

Reply