Skip to main content
Question

How to reset counter to 0 for each incoming file?


makt
Contributor
Forum|alt.badge.img+1
  • Contributor
I have 10 shapefiles that I firest put through a counter, then attribute creator, which uses the counter to fill in "new_att", then I write out 10 new shapefiles with the additional attribute (by fanning based on basename)

 

 

Say I want "new_att" to = count. How can I "reset" the count so that each of the shp files will start at 0 rather than keep going from where it ended on the last file?

 

 

I thought that the "local" vs "global" setting controled this behavior but it seems not to make a difference. 

 

 

 

5 replies

Forum|alt.badge.img
  • May 28, 2014
Hi

 

If you set the "counter name" parameter of the counter to an unique value for each shapefile (basname for example) it will group the counting of all features with said value.

 

Global means the counting for this feature is made over the whole workspace whereas local means the counting is only considered in this transformer.

 

I hope this helps.

 

Simon

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 28, 2014
Use the counter name  as Simon said.

 

 

Create a dynamic grouping attribute like for instance this:

 

 

First do a counter on all items. (as i created objects, i used the creation instance)

 

Then create a attribute on your objects:

 

Grouper = -count/10 (do not use decimal point!)

 

Now u can set a new counter with counter name = Grouper

 

 

 

 

 

Greets

owen
Forum|alt.badge.img+1
  • May 28, 2014
You can do this with a adding a custom transformer with a counter in it, and use 'parallel processing' grouped by fme_feature_type. This will reset the count for each shapefile:

 

 

 


makt
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • May 28, 2014
Simon - thanks, that worked with the least amount of clicking around!

 

Gio - another good approach - I didn't try it out but from what I understand, your model would need to be further tuned if each incoming shp file had different # of rows in the attribute table? (which is my case)

 

Owen - got your model working too! Seems to be a lot more clicking than Simon's solution, but I think your approach might be interesting to work with in more complex workspaces!

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • June 2, 2014
I just used the "grouping generation" as an example.

 

U could have it change per featuretype. But when your featuretypes have different names anyway, u just use fme_featuretype as counter name (of course)

 

 

But it shows the flexibility of generating groups within  a featuretype, u could use math for instance to create groupings. Or u could use a table, with fixed values and a merger to create a fixed grouping scheme.

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