1

I am running a number of spatial queries on a dataset in model builder and want the number of selected features to be saved in a table. I don't want the features themselves but just the number of features that the query found. Is this possible?

enter image description here

I want

ID| Site | Number

1 | Brisbane | 9789

2 | Towoomba | 8389

etc...

3
  • 2
    Perhaps a summary statistics with count of OID/FID. The options in model builder are somewhat limited. There is a get count tool but that's used for branching and the output of such I don't think can be logged. Commented May 26, 2014 at 5:04
  • Thanks, just thinking about it further, I will look at using forums.arcgis.com/threads/… and maybe outputting to a collect values tool.
    – GeorgeC
    Commented May 26, 2014 at 7:01
  • 1
    Summary Statistics as suggested by @MichaelMiles-Stimson is how I would do this.
    – PolyGeo
    Commented May 26, 2014 at 7:59

2 Answers 2

1

Using the summary statistics tool will only get you half way there, it will give you one table per selection with the count of unique FID/OID. Geoprocessing tools honor selection layers and will only sum the selected features.

To compile the tables into a single table it is necessary to, for each sum table, add a Site field and calculate the name. Then the tables can be merged and exported to text format in the model. This will not do pipe delimited, to achieve this it is necessary to open the csv file and find & replace "," with "|".

As stated in the comment, there is a Get Count tool for modelbuilder but this is for condition branching and I don't know a way to get the output of this into a file using just modelbuilder. In python it wouldn't be a problem, the count could be written to a text file in pipe delim format using file operations!

0

Thanks Everyone...

In the end it was quicker just to write a small script to get this with the Get Count Tool.

The script is

import arcpy
id=arcpy.GetParameterAsText(0)
fieldName=arcpy.GetParameterAsText(1)
RowCount=arcpy.GetParameterAsText(2)
logFile=r'D:\scratch\GetCountTool_output.txt'
log = open (logFile, 'a')
log.write(id+"|"+fieldName+"|"+RowCount)
log.close

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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