Skip to main content
Question

Create triangles using attributes

  • February 20, 2013
  • 5 replies
  • 64 views

geolassi
Contributor
Forum|alt.badge.img+5
Hello!

 

 

I have CSV data which contains triangles. Each row contains one triangle. The triangle is defined by 6 attributes, x0, y0, x1, y1, x2 and y2. Is there a way to create polygon geometry using a transformer from those 6 attributes? I'm using StringConcatenator to create FME XML Geometry and GeometryReplacer. It works, but it would be useful to have a transformer, which could do that, something like Creator, but with INPUT port, since Creator doesn't have INPUT.

5 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • February 20, 2013
Hi,

 

 

My idea is: expose csv_line_number format attribute, connect the CSV reader to three 2D/3DPointReplacers parallel to create 3 points per a line, join them into a Sorter and sort points by csv_line_number, and connect each 3 points by PointConnector (Group by csv_line_number).   

geolassi
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • February 20, 2013
Thank you Takashi, I was just thinking too complicated solution. Simple is the best. I had to add fourth 2DPointReplacer to get polygons from PointConnector.

 

 

What if I don't have triangles, but polygons in the CSV file, and I wouldn't know the vertex number of a polygon. I guess I would need some kind of loop structure with each feature having the vertices in a list.

davideagle
Contributor
Forum|alt.badge.img+19
  • Contributor
  • February 20, 2013
That should work as long as you can loop to the end of the list creating one point each time. I'd probably go for variablesetters and retrievers though. Read each line and explode all the X&Y values into features and use the csv line number as the feature ID. Then as Takashi says a PointConnector perhaps followed by a GeometryCoercer to create the polygons.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • February 20, 2013
Alternatively, LineCloser is also available to change a line consisting of 3 or more vertices to a polygon.

mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • February 21, 2013
If you use the 2DPointAdder (instead of replacer) and keep adding to the same feature, FME will automatically turn it into a polygon.

 

 

The other method of changing a closed line to a polygon is the GeometryCoercer

Reply


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