Начало работы с Python
Начало работы с Python в ArcGIS Pro | Documentation
Под Новым проектом щелкните Карта. В окне Новый проект в поле Имя введите Начало работы с Python. В опции Местоположение укажите свою папку C:\PythonStart. Сни ...
Посчитать строки
Если вы посетите раздел справки <anchor>Посчитать строки</anchor> в разделе Параметры, щелкните Python и вы увидите, что в этом разделе есть пример кода. Примеры Python включены во все разделы справки по инструментам геообработки.
Get Count (Data Management)—ArcGIS Pro | Documentation
Get Count (Data Management)—ArcGIS Pro \| Documentation

Back to Top

# Get Count (Data Management)

#### In this topic

1. [Summary](#S_GUID-9FAE090B-E729-4EFB-970E-EAE6E6F29A4C)
2. [Usage](#ESRI_USAGES_00B988EAF678449884E9557FE800D2AC)
3. [Parameters](#GUID-CA8FF820-021B-4EB4-B5D6-FA31F23415B0)
4. [Environments](#GUID-F3ED0B41-96E5-496E-BDD1-CAB3F1899477)
5. [Licensing information](#L_)

## Summary

Returns the total number of rows for a table.

## 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 [Extent](/en/pro-app/3.3/tool-reference/environment-settings/output-extent.htm) environment. Only those features that are within or intersect the Extent environment setting will be counted.

- You can view the returned row count in [Geoprocessing history](/en/pro-app/3.3/help/analysis/geoprocessing/basics/geoprocessing-history.htm).

- In ModelBuilder, Get Count can be used to set up a precondition, as illustrated below. In this model, Get Count counts the number of records returned by the [Select](/en/pro-app/3.3/tool-reference/analysis/select.htm) tool. If the count is zero, Buffer will not run due to the precondition.
![Using Get Count with a precondition](GUID-7F52C405-0975-4E42-BB90-46D4B433DCBF-web.png)

## Parameters

DialogPython

LabelExplanationData Type

Input Rows

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

Table View; Raster Layer

### Derived Output

LabelExplanationData TypeRow Count
The total number of rows for the input.
Long

```
arcpy.management.GetCount(in_rows)
```

NameExplanationData Type

in\_rows

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

Table View; Raster Layer

### Derived Output

NameExplanationData Typerow\_count
The total number of rows for the input.
Long

### Code sample

GetCount example 1 (Python window)

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

```python
import arcpy
arcpy.env.workspace = "C:/data/data.gdb"
arcpy.management.GetCount("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.

```python
# Purpose: Calculate the number of features in a feature class

# Import system modules
import arcpy

lyrfile = r"C:\data\streets.lyr"
result = arcpy.management.GetCount(lyrfile)

# Print the number of features using the Result object
print('{} has {} records'.format(lyrfile, result[0]))
```

## Environments

[Current Workspace](/en/pro-app/3.3/tool-reference/environment-settings/current-workspace.htm), [Extent](/en/pro-app/3.3/tool-reference/environment-settings/output-extent.htm)

## Licensing information

- Basic: Yes
- Standard: Yes
- Advanced: Yes

#### Related topics

- [An overview of the Table toolset](/en/pro-app/3.3/tool-reference/data-management/an-overview-of-the-table-toolset.htm)
- [Find a geoprocessing tool](/en/pro-app/3.3/help/analysis/geoprocessing/basics/find-geoprocessing-tools.htm)

* * *

[Feedback on this topic?](/feedback/)

##### In this topic

1. [Summary](#S_GUID-9FAE090B-E729-4EFB-970E-EAE6E6F29A4C)
2. [Usage](#ESRI_USAGES_00B988EAF678449884E9557FE800D2AC)
3. [Parameters](#GUID-CA8FF820-021B-4EB4-B5D6-FA31F23415B0)
4. [Environments](#GUID-F3ED0B41-96E5-496E-BDD1-CAB3F1899477)
5. [Licensing information](#L_)