Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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...

share|improve this question
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. –  Michael Miles-Stimson May 26 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 May 26 at 7:01
1  
Summary Statistics as suggested by @MichaelMiles-Stimson is how I would do this. –  PolyGeo May 26 at 7:59

2 Answers 2

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!

share|improve this answer
up vote 0 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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