Skip to main content

The thing is some of the coordinates only have 2 points and some have 30+ to make up the lines. I can use AttributeSplitter and create lists, but they are inconsistent when I try to pull out the list using AttributeCreator as some only have 2 and some have 30+. I can split it using ",0;" and then split it again into a separate lat/long for each point. It seems like there has to be an easier way.

 

How would should I go about extracting all of these lat/longs into a line? LineBuilder isn't working for me.

 

Capture 

Thanks!

Can you post an example?


Just took a screenshot of the column.


So one possible way

Use an attribute splitter splitting at the ; to get a list of coordinates, explode this list so you have a feature per coordinate, a second attribute splitter splitting at , to split x,y and z coordinates. Use a vertex creator to create the points from these list items, then a line builder to join into lines

Capture


So one possible way

Use an attribute splitter splitting at the ; to get a list of coordinates, explode this list so you have a feature per coordinate, a second attribute splitter splitting at , to split x,y and z coordinates. Use a vertex creator to create the points from these list items, then a line builder to join into lines

Capture

Do I use AttributeExploder after AttributeSplitter? Splitter, Exploder, Splitter, VertexCreator? Won't this only give you two coordinates for each line?


Awesome! Thank you so much!


Do I use AttributeExploder after AttributeSplitter? Splitter, Exploder, Splitter, VertexCreator? Won't this only give you two coordinates for each line?

The AttributeSplitter (splitting on ";") will create an FME List of coordinates. Like:

  • Feature 1:
    • List Item 1: x,y
    • List Item 2: x,y
    • List Item 3: x,y
  • Feature 2:
    • List Item 1: x,y
    • List Item 2: x,y
  • Feature 3:
    • List Item 1: x,y
    • etc

Then the ListExploder (not AttributeExploder) will give you a feature per coordinate pair.

  • Feature 1: x,y
  • Feature 2: x,y
  • Feature 3: x,y
  • Feature 4: x,y
  • Feature 5: x,y
  • Feature 6: x,y
  • etc

The next AttributeSplitter extracts the x from the y and the VertexCreator now converts those to point features.

The LineBuilder at the end joins the points together where they belong to the same original feature.

So, yes, AttributeSplitter, ListExploder, AttributeSplitter, VertexCreator, LineBuilder.

 


Another solution would be to encode the coordinates inside a standard micro-format that FME can convert with the GeometryReplacer.

For example, with your data as:

5,5;12,5;15,7

Use a StringConcatenator to add 

LINESTRING(

to the front of the coordinate list and add

)

to the end.

Now use a StringReplacer to replace , with a <space> character and ; with , which will give:

LINESTRING (5 5,12 5,15 7)

FME can now create the geometry automatically from that string with the GeometryReplacer transformer, where Geometry Encoding = WKT Well Known Text

 

 


Another solution would be to encode the coordinates inside a standard micro-format that FME can convert with the GeometryReplacer.

For example, with your data as:

5,5;12,5;15,7

Use a StringConcatenator to add 

LINESTRING(

to the front of the coordinate list and add

)

to the end.

Now use a StringReplacer to replace , with a <space> character and ; with , which will give:

LINESTRING (5 5,12 5,15 7)

FME can now create the geometry automatically from that string with the GeometryReplacer transformer, where Geometry Encoding = WKT Well Known Text

 

 

I think they're y,x,z which complicates matters​


I think they're y,x,z which complicates matters​

It certainly would!


Sounds like a Safe Software interview question 😏


Reply