Solved

how do i detect 2D lines and how to change height of these lines base on some attribute

  • 29 August 2016
  • 8 replies
  • 20 views

First let me say that I'm extremely new to fme environment.

I have a shape file that have lines with or without elevation.

My problem is that i need to separate these 2D lines, and to set the elevation base on 1 attributes in the feature and also export the other 2D lines that has the very same attribute null.

These 2 types of lines need to be exported separately.

In one export i need to export all 3D features (including the original 3D and the one that i created with the attribute value) and in the other one only the feature that has no elevation

icon

Best answer by mark2atsafe 29 August 2016, 17:09

View original

8 replies

Badge +16

Hi,

Welcome to the wonderful world of FME!

To force something into 3D based on an attribute see the 3DForcer transformer, just type 3D in the canvas and select the correct transformer.

Where do you need to export these lines to? which target format?

Userlevel 2
Badge +12

To test if a feature is 2D or 3D I would extract the coordinates of the first vertex (CoordinateExtractor using index = 0) with a default value for Z being -9999. These are the default settings for the transformer.

Next you can test (Tester) for all features having Z=-9999.

Then as @itay said use the 3DForcer on the features having Z=-9999 to set the Z value from the selected attribute.

To test if a feature is 2D or 3D I would extract the coordinates of the first vertex (CoordinateExtractor using index = 0) with a default value for Z being -9999. These are the default settings for the transformer.

Next you can test (Tester) for all features having Z=-9999.

Then as @itay said use the 3DForcer on the features having Z=-9999 to set the Z value from the selected attribute.

well these 2D lines has actually Z=0

 

And it might be also polylines not just lines.

 

I was thinking something like adding all Z values from each vertex on the line, in modules, and if the sum is 0 then it is a 2D line. but again i don't know how to do that.

 

Also about the 3DForcer what is the rejected feature? is the features that the attribute has null value?

 

 

Userlevel 2
Badge +12
well these 2D lines has actually Z=0

 

And it might be also polylines not just lines.

 

I was thinking something like adding all Z values from each vertex on the line, in modules, and if the sum is 0 then it is a 2D line. but again i don't know how to do that.

 

Also about the 3DForcer what is the rejected feature? is the features that the attribute has null value?

 

 

The rejected feature is a feature that can not be converted into a 3D geometry (usually a non-spatial geometry).

 

Getting all Z values can be done using the CoordinateConcatenator (selecting only the Z). This will get you a comma separated list. You can convert that into an array using the AttributeSplitter and the get the sum using the ListSummer.

 

 

Userlevel 4
Badge +25

It sounds like you just want to filter the features depending on whether they are 2D or 3D.

2D lines have a Z value of zero (0) but equally a 3D line could include a zero Z value at some point.

So, to use the methodology you suggested, try this:

  • A CoordinateConcatenator, to concatenate only Z values into a comma delimited string
  • An AttributeSplitter to split that attribute string into an FME "list"
  • A ListRangeExtractor to find the maximum value for that list
  • A Tester to test if Max > 0

If Max > 0 then it is 3D. If Max=0 then it is 2D.

Attached is a 2dvs3dlines.fmwt. Hope this helps, and welcome to both FME and the FME Q+A forum!

Mark

ps - I'm just writing a Data QA tutorial for FME and this is a great example to include, so thanks for giving me the idea!

pps - I just noticed @erik_jan gave the same method in the time it was taking me to write this. Well, they do say that great minds think alike!

It sounds like you just want to filter the features depending on whether they are 2D or 3D.

2D lines have a Z value of zero (0) but equally a 3D line could include a zero Z value at some point.

So, to use the methodology you suggested, try this:

  • A CoordinateConcatenator, to concatenate only Z values into a comma delimited string
  • An AttributeSplitter to split that attribute string into an FME "list"
  • A ListRangeExtractor to find the maximum value for that list
  • A Tester to test if Max > 0

If Max > 0 then it is 3D. If Max=0 then it is 2D.

Attached is a 2dvs3dlines.fmwt. Hope this helps, and welcome to both FME and the FME Q+A forum!

Mark

ps - I'm just writing a Data QA tutorial for FME and this is a great example to include, so thanks for giving me the idea!

pps - I just noticed @erik_jan gave the same method in the time it was taking me to write this. Well, they do say that great minds think alike!

thank you.

 

Now i can test both min and max value for 0. if both are 0 then i know its a 2D lines.

 

Its not enough to just sum them cause i might get some minus values on the line.But with ListRangeExtractor i can make sure the line is 2D.

 

 

Badge +3

of course you would want to test if max z < 0 too...seems 3D to me.

Apart from that neither test prove the objects are 2d or 3d.

2D geometry simply has no z component.

The tests you suggest simply assume that objects are 3D if they are above some 0-plane in not the x or y plane.

Focussing on any axis an object is 2D if it has no range in one of the planes.

of course you would want to test if max z < 0 too...seems 3D to me.

Apart from that neither test prove the objects are 2d or 3d.

2D geometry simply has no z component.

The tests you suggest simply assume that objects are 3D if they are above some 0-plane in not the x or y plane.

Focussing on any axis an object is 2D if it has no range in one of the planes.

true. but in my case all lines has Z values. So for me its exactly what i need. I have no other way to find these lines.

 

Reply