2

Specs: I'm using ArcInfo 10.1 and have all extensions available to me.

I have a folder with many file geodatabases.

Each file geodatabase contains 2 feature classes. One is a point fc and the other is a polygon fc.

I'm trying to figure out how to calculate the total number of polygons stored in all geodatabases in this folder. I'm happy for this number to go anywhere i.e .txt, .csv, .xls, even just a box somewhere so I can write it down.

I think I'm nearly there with ModelBuilder, but I'm stuck at what I believe is the last step.

My logic:

1 - Use an iterator to iterate through all the fgdb's in the folder.

2 - Use an iterator to iterate through the feature classes in the fgdb looking only at the polygon feature type.

3 - Use the Get Count tool to count the number of rows in the feature class.

4 - This is where I'm stuck. I think I want to be using the Collect Values tool to collect all off the returned polygon counts, but I can't figure out how to extract and sum the values from here. Am I thinking about this in completely the wrong way?

Iterate Workspace

Iterate Feature class

1

You are close.
In both models you will need to add the model only tool Calculate Value. The output of that tool should also be an output parameter of the inner model.
You can't use the output of collect values as the input directly so set it as the precondition.
Then set the expression of Calculate Value to:

    sum_counts('%Row Counts%')

%Row Counts% is the name of the output from Collect Values (defaults to output_value). Be sure to include the quotes.

And, the code block should be:

    def sum_counts(counts):
        if counts.find(';') == -1:
            if counts <> '#': return int(counts)
            else: return 0
        else:
             return sum(map(int, counts.split(';')))

The output value from the Calculate Value tool in your upper model should be the total count: Iterate Folder enter image description here

P.S. I'd recommend a Python script for this sort of thing. If you haven't checked it out much, it would be worth the time.

  • Thanks for this. It did exactly what I need. I also managed to get the value a different route which I'll post as an image below. – Dan_h_b Dec 4 '13 at 15:18
1

The images below are a different way to solve this. In the Summary statistics tool I am collecting the Count of the ObjectID field and then appending this into a pre-existing empty table.

enter image description here

enter image description here

  • 1
    Whilst Evil genius is using some nifty python I prefer this approach as it keeps it all model builder based so easier to follow. Just an idea, after your summary tool output you could put in an add field then calculate tool (name of workspace) before you append so you can report the counts by workspace if you needed to? – Hornbydd Dec 4 '13 at 17:47
  • @Hornbydd: I tried something to this effect but my table comes out empty. Do you know why? See my post here: gis.stackexchange.com/questions/297189/… – val Sep 27 '18 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.