Question

Help with counting, comparing, as a condition for execution?

  • 30 September 2016
  • 4 replies
  • 19 views

I have a SQLCreator that returns x number of features, and FeatureMerger that returns y number of features. I then want to compare the two counts (Does x = y?) and if that is false, then I want to do certain things, including generating a string (for logging or notification) that is something like "Table1 has x features and Table2 has y features."

I can get the respective counts (StatisticsCalculator), and I can compare the counts (Tester) and I can (incorrectly) generate the string (StringConcatenator). My problem is more about storing/saving values, and regulating their population and use.

For example, two counts comes in as two features, so I get two comparisons, and two strings:

  • Table1 has x features and Table2 has <null> features.
  • Table1 has <null> features and Table2 has y features.

FeatureHolder seems only to delay the inevitable. What am I not fundamentally understanding about feature processing that is making this harder than it should be?

Thank you very much!


4 replies

Badge +16

Hi @samuelvaldez have you tried grouping the two counts via a common value and using the group by setting in the statistics calculator ?

Userlevel 4

Use another FeatureMerger with a dummy merge criteria, e.g. 1 = 1. As long as the two counts are named differently you should end up with one feature with both attributes. It is then simple to use a Tester to check for equality.

Example:

Userlevel 4
Badge +25

Yes, there are a few solutions. The general flow of features in FME means everything is separate, and the Tester only tests one feature at a time. So you don't test feature 1 against feature 2 in a Tester.

Some solutions:

1 - as mentioned, merge the information onto a single feature using the FeatureMerger, then a Tester

2 - use the FeatureMerger but merge by count. If the features merge, they are a match. If not, not.

3 - Use a transformer that accepts two features for comparison, for example the ChangeDetector.

4 - Use "Adjacent Feature Attributes". In an AttributeManager turn that on. Then you can say diff = count - count[-1] if the result is zero, then there is a match

I have a variation on the question above. I have a Parcel feature class in a Parcel Publishing feature dataset in our enterprise ArcGIS/SQL geodatabse that is truncated and recompiled nightly based on data in our Parcel Fabric using a combo of py and fme and Windows Task Scheduler. One of the scripts failed this week and incomplete data was written to the output dataset. Can’t have that happen again! I want to build a failsafe into my scripting that would:

 

  • Compare record counts from the old data and the new data
  • If the counts are beyond a threshold (say + or - 50 records), do not write the new output

Right now, because FME 2017 (to my knowledge) can’t work with Parcel Fabric feature classes, I have py scripting that compiles the new data to a file gdb and the fme scripting does the truncate and replace steps. Suggestions for adding the above failsafe to my fme script?

 

Here are my software and db details:
  • FME Desktop 2017
  • ArcGIS 10.4.1
  • SQL Server 2014

Reply