ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Get Count

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Returns the total number of rows for a feature class, table, layer, or raster.

Usage

  • If the input is a layer or table view containing a selected set of records, only the selected records will be counted.

  • This tool honors the Output Extent environment. Only those features that are within or intersect the Output Extent environment setting will be counted.

  • You can view the returned row count in the Results window.

  • In ModelBuilder, Get Count is typically used to set up a precondition, as illustrated below. In this model, Get Count counts the number of records returned by the Select tool. If the count is zero, Buffer will not run due to the precondition.

    Using Get Count with Precondition

Syntax

GetCount_management (in_rows)
ParameterExplanationData Type
in_rows

The input table view or raster layer. If a selection is defined on the input, the count of the selected rows is returned.

Raster Layer; Table View

Code sample

GetCount example 1 (Python window)

The following Python Window script demonstrates how to use the GetCount function in immediate mode.

import arcpy
from arcpy import env

env.workspace = "C:/data/data.gdb"
arcpy.GetCount_management("roads")
GetCount example 2 (stand-alone script)

The following stand-alone script is an example of how to use the GetCount function in a scripting environment.

# Name: fcCount.py
# Purpose: calculate the number of features in a featureclass

# Import system modules
import arcpy
 
lyrfile = r"C:\data\streets.lyr"
result = arcpy.GetCount_management(lyrfile)
count = int(result.getOutput(0))
print(count)

Environments

  • Current Workspace
  • Extent

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Table toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal