Question

DGN to CSV

  • 13 June 2013
  • 7 replies
  • 28 views

Badge +1
I am trying to extract x, y and z values out of a DGN file into a CSV file.  I used the following transformers: CoordinateConcatenator, AttributeSplitter and ListExploder.  Everything works except that the output has each x, y and z value in a separate row rather than all in one row.  Does anyone know how to change this?

7 replies

Userlevel 3
Badge +17
Hi,

 

 

Two AttributeSplitters might help you. Specify different characters as the 'Coordinate Delimiter' and 'Coordinate Element Delimiter' parameter of the CoordinteConcatenator e.g. '-' for the former, ',' for the latter. Split the concatenated coordinates at '-' (the 1st AttributeSplitter), explode the list (ListExploder). Split the exploded list element at ',' (the 2nd AttributeSplitter), then expose the split 3 element i.e. (x, y, z).

 

Takashi
Badge +1
Hi Takashi,

 

 

Thankyou for your quick reply.

 

 

I'm quite new to FME and was hoping you could explain that step by step.  Ie: do the two AttributeSplitters come out of the one CoordianteConcatenator and then do they go back into the one ListExploder or are there two ListExploders?

 

 

Thanks
Userlevel 3
Badge +17
Hi,

 

 

Those transformers should be connected in a series, and there is only one ListExploder. For example, when a feature consist of 3 coordinates - (0, 1, 2), (3, 4, 5), (6, 7, 8) -, they will work like:   CoordinateConcatenator creates a concatenated coordinates string. "0,1,2-3,4,5-6,7,8"   --> AttributeSplitter splits the concatenated coordinates into a list. list{0} = "0,1,2" list{1} = "3,4,5" list{2} = "6,7,8"   --> ListExploder explodes the list and creates new features, each of them contains a coordinate. "0,1,2" "3,4,5" "6,7,8"   --> AttributeSplitter splits coordinate into a list list{0} = "0" list{1} = "1" list{2} = "2" list{0} = "3" list{1} = "4" list[2} = "5" list{0} = "6" list{1} = "7" list{2} = "8"   After exposing the list element (x, y, z), you can write them in a row of a csv file. I hope my explanation is enough to help your understanding.

 

 

Takashi  
Userlevel 3
Badge +17
Alternatively, you can use the Chopper  and the CoordinateExtractor. The Chopper (Mode: By Vertex, Maximum Vertices: 1) can break a feature into vertices. This approach may be easier :-)

 

Takashi
Badge +1
Thanks Takashi, that was really helpful!  I used your first method with the two Attribute Splitters!
Badge +1
Am I missing something critical here?  I do this procedure all the time, and all it takes is a CoordinateExtractor and the CSV writer.

 

 

Why is everyone talking about concatenating and splitting?
Userlevel 3
Badge +17
Hi,

 

 

> Why is everyone talking about concatenating and splitting?

 

 

In many cases, there are several approaches to do the same thing. I think, as a generality, which approach is adopted should be determined after considering various viewpoints e.g. efficiency, usability, maintainability etc. As you said, the CoordinateExtractor would be effective in this case (especially if the input feature geometry were point), however, there has been a workspace with CoordinateConcatenator + ListExploder + AttributeSplitter already and it works almost well, so adding one more AttributeSplitter rather than removing all of existing transformers could be a simple solution. I think it is also an adoptable approach from the viewpoint of developement efficiency. This is why I talked about the CoordinateConcatenator first and mentioned about the CoordinateExtractor finally.

 

 

Takashi

Reply