Question

Selection with condition

  • 19 September 2018
  • 13 replies
  • 3 views

Badge +6

I have a lot of lines with two attributes

 

Attr. 1 Count from 1 to xxxxxxx

Attr. 2 Range set default as 0

Now i have to make a loop workflow...

 

-Select lowest number from attr.1 and set attr.2 with "1"

 

now go all other lines through and check if there is a segment equal than the first feature we selected (many lines have same segments...in the end i want only 1 line per segment )

if there are detected same segments delete these lines

after that select the next lowest number in attr. 1 which are still available and set attr.2 with "2"

and so on and so on

i will try it by myself, but any ideas are welcome

Cheers

Franco


13 replies

Badge +6
Ok...i try to explain in little steps....

 

 

I have a lot of lines with 2 important attrbs:

 

Attr1 is filled with numbers from 1 to xxxxxx

 

Attr 2 is default "0"

 

 

Step1:

 

in the first loop i select the feature with the minimum value in Attr1 which is in the first loop "1"

 

the i have to set for this feature Attr2 from "0" to "1"

 

now i have to compare all other lines with this feature if there are common geometry....

 

if that is yes deleted these other lines

 

 

Step2:

 

in the second loop i select the feature with the minimum value in Attr1 which has also Attrb2 still on "0"

 

for this feature i set the Attr2 from "0" to "2"

 

now i have to compare all other lines (which have of course still "0" in Attr2 ) with this feature if there are common geometry....

 

if that is yes deleted these other lines

 

 

Step3:

 

in the third loop i select the feature with the minimum value in Attr1 which has also Attrb2 still on "0"

 

for this feature i set the Attr2 from "0" to "3"

 

now i have to compare all other lines (which have of course still "0" in Attr2 ) with this feature if there are common geometry....

 

if that is yes deleted these other lines

 

 

and so on and so on

 

 

@Step2:

 

of course next feature HAS NOT always have "2" in Attrb2 because if the feature with this attrb has common geometry with feature 1 it is already deleted......

 

 

 

 

 

Userlevel 2
Badge +19
Any chance you could share a sample of your data? We would need to invest some time in order to build something similar.

 

 

Badge +6
Any chance you could share a sample of your data? We would need to invest some time in order to build something similar.

 

 

https://wetransfer.com/downloads/bfe660f08dbde527df695872550476cf20180920074105/a4774befa87f38fef91dfd4602dabc0820180920074105/50a24e

 

 

Badge +6
Any chance you could share a sample of your data? We would need to invest some time in order to build something similar.

 

 

this is a shape file ...and Attr1 is "Rang" and Attr2 is "auf_gew"...so one fetaure is through manually...thats the one with Attr1 "1" and auf_gew "1"...

 

 

Userlevel 2
Badge +17
Hi @franco69, I cannot access your shared file. Could you please check if the URL is correct?

 

Does "common geometry" mean the two geometries are exactly same?
Badge +6
Hi @franco69, I cannot access your shared file. Could you please check if the URL is correct?

 

Does "common geometry" mean the two geometries are exactly same?
i will check it...common geometry means segments have to be the same...means not intersections or touches

 

 

 

Badge +6
i will check it...common geometry means segments have to be the same...means not intersections or touches

 

 

 

https://wetransfer.com/downloads/bfe660f08dbde527df695872550476cf20180920074105/ddd4fe

 

 

 

Userlevel 4
Badge +25

I honestly think there are easier ways of achieving this without looping (if I am correct in what you want to do). It seems to me you just want to remove duplicate geometry, but keep the one with the lowest ID number.

So, for example, represent geometry as an attribute using a CRCCalculator (or a GeometryExtractor), then use a Sorter to sort by ID (lowest to highest), and a DuplicateFilter to filter our duplicate geometry values.

That should work because you keep the lowest ID feature (it is first because you sorted by that) and duplicates have a higher ID and are removed.

I'll try it with your data, but it sounds to me like this is what you are asking.

Edit: Tried with your data. Does this look like the numbers you are expecting?

Badge +6

I honestly think there are easier ways of achieving this without looping (if I am correct in what you want to do). It seems to me you just want to remove duplicate geometry, but keep the one with the lowest ID number.

So, for example, represent geometry as an attribute using a CRCCalculator (or a GeometryExtractor), then use a Sorter to sort by ID (lowest to highest), and a DuplicateFilter to filter our duplicate geometry values.

That should work because you keep the lowest ID feature (it is first because you sorted by that) and duplicates have a higher ID and are removed.

I'll try it with your data, but it sounds to me like this is what you are asking.

Edit: Tried with your data. Does this look like the numbers you are expecting?

Thank you Mark....i didnt work with the CRCCalculator yet....and i didnt know that FME automatically keeps the lowest ID after a sort.

 

 

Cheers

 

Franco

 

 

Badge +6

I honestly think there are easier ways of achieving this without looping (if I am correct in what you want to do). It seems to me you just want to remove duplicate geometry, but keep the one with the lowest ID number.

So, for example, represent geometry as an attribute using a CRCCalculator (or a GeometryExtractor), then use a Sorter to sort by ID (lowest to highest), and a DuplicateFilter to filter our duplicate geometry values.

That should work because you keep the lowest ID feature (it is first because you sorted by that) and duplicates have a higher ID and are removed.

I'll try it with your data, but it sounds to me like this is what you are asking.

Edit: Tried with your data. Does this look like the numbers you are expecting?

Hi Mark....your solution works, but it is for lines which have exact same geometry...

 

how is the transformer called if i want to delete the lines which have (like in ARCGIS "share a segment with") partial same geometry......then CRCCalculator can not help me anymore or?

 

 

Greetz and Cheers

 

Franco

 

 

Userlevel 4
Badge +25
Hi Mark....your solution works, but it is for lines which have exact same geometry...

 

how is the transformer called if i want to delete the lines which have (like in ARCGIS "share a segment with") partial same geometry......then CRCCalculator can not help me anymore or?

 

 

Greetz and Cheers

 

Franco

 

 

Well, that's a little harder. The SpatialFilter/SpatialRelator can look for overlaps, but they work with two sets of input features, where you only have one. But what you can do is point the input into both ports. So add a SpatialRelator, set Support Mode = Support all Predicates, and set the Spatial Predicates to Test to "Requestor Overlaps Supplier".

 

 

This will tell you which features have an overlap at any point. The trick now is to figure out how to get the one with the lowest ID. I think you can do that by creating a list in the SpatialRelator (adding ID to the list) and then using a Tester to test where relationships > 1 (ie there is a match) AND ID < lowest list ID.

 

 

I may still be reading your question wrong, and you want to keep both lines, but split them up and only keep the section that overlaps once. To do that follow up with a LineOnLineOverlayer, create a list of features that match in an overlap, sort them and pick the first set of attributes.

 

 

Here is a workspace that demonstrates the techniques. It uses bicycle paths in Vancouver. In one part (blue bookmark) where there is an overlap between two bicycle paths, it chooses the one with the lower ID. In the other part (yellow bookmark) where there is an overlap it keeps both paths but the overlapping section is only included once.

 

 

Try running this and examining the output at each stage and you will see how it works.

 

Userlevel 4
Badge +25
Well, that's a little harder. The SpatialFilter/SpatialRelator can look for overlaps, but they work with two sets of input features, where you only have one. But what you can do is point the input into both ports. So add a SpatialRelator, set Support Mode = Support all Predicates, and set the Spatial Predicates to Test to "Requestor Overlaps Supplier".

 

 

This will tell you which features have an overlap at any point. The trick now is to figure out how to get the one with the lowest ID. I think you can do that by creating a list in the SpatialRelator (adding ID to the list) and then using a Tester to test where relationships > 1 (ie there is a match) AND ID < lowest list ID.

 

 

I may still be reading your question wrong, and you want to keep both lines, but split them up and only keep the section that overlaps once. To do that follow up with a LineOnLineOverlayer, create a list of features that match in an overlap, sort them and pick the first set of attributes.

 

 

Here is a workspace that demonstrates the techniques. It uses bicycle paths in Vancouver. In one part (blue bookmark) where there is an overlap between two bicycle paths, it chooses the one with the lower ID. In the other part (yellow bookmark) where there is an overlap it keeps both paths but the overlapping section is only included once.

 

 

Try running this and examining the output at each stage and you will see how it works.

 

Looking at my workspace, the first ListSorter could/should go into the blue bookmark, and the connection to Tester_2 in the yellow bookmark could come from the SpatialRelator. But it doesn't really matter, other than to sort a list that the second part doesn't use.

 

 

Userlevel 2
Badge +17

I honestly think there are easier ways of achieving this without looping (if I am correct in what you want to do). It seems to me you just want to remove duplicate geometry, but keep the one with the lowest ID number.

So, for example, represent geometry as an attribute using a CRCCalculator (or a GeometryExtractor), then use a Sorter to sort by ID (lowest to highest), and a DuplicateFilter to filter our duplicate geometry values.

That should work because you keep the lowest ID feature (it is first because you sorted by that) and duplicates have a higher ID and are removed.

I'll try it with your data, but it sounds to me like this is what you are asking.

Edit: Tried with your data. Does this look like the numbers you are expecting?

Basically the LineOnLineOverlayer does that. Also, since there are many duplicate lines in the source dataset, the Matcher can be used to remove duplicates beforehand, in order to increase the performance.

 

Example: esrishape2none-2.fmwt (FME 2018.1.0.2)

 

Note: In my testing, some "Rang" lines have been split into multiple parts. Check if the result is your expected.

 

Reply