HOW TO

Delete empty feature class using ArcPy in ArcGIS Pro

First Published: August 5, 2026
Last Published: August 5, 2026

Summary

In ArcGIS Pro, an empty feature class is a feature class that exists but contains no feature records. These empty feature classes can be deleted using ArcPy to improve data maintenance and ensure a well-organized geodatabase structure. This article demonstrates the workflow to delete the two empty feature classes, Buildings and Routes, as found in the Catalog pane below, using ArcPy.

The feature classes in the Catalog pane

Procedure

Note: 
This workflow requires a full script to run in the ArcGIS Pro Python window. The indents must be retained as portrayed in the code block.
  1. In ArcGIS Pro, click the Analysis tab. In the Geoprocessing group, click the Python drop-down menu and select Python Window.
  2. In the Python window, configure the script.
    1. Import the ArcPy module.
import arcpy
    1. Specify the workspace with the file geodatabase folder path in <gdbFolderPath>.
gdb = r"<gdbFolderPath>"
arcpy.env.workspace = gdb
    1. Access the current project and active map.
aprx = arcpy.mp.ArcGISProject("CURRENT") 
m = aprx.activeMap
    1. The m.listLayer() function is used to retrieve the feature class layers in the map. The m.removeLayer() function is then used to remove the selected feature class layer from the map. In this example, 'fc_name' is used as the reference to identify the target layer and is compared with 'lyr.name' to ensure only the matching feature class is selected.
for fc_name in arcpy.ListFeatureClasses(): 
if int(arcpy.management.GetCount(fc_name)[0]) == 0:
for lyr in m.listLayers():
if lyr.name == fc_name:
m.removeLayer(lyr)
print(f"Removed from map: {fc_name}")
    1. Specify the arcpy.Exists() function to verify whether the feature class exists at the defined geodatabase path before it is deleted. If the feature class exists, the arcpy.management.Delete() function is used to delete it from the file geodatabase.
        arcpy.management.Delete(fc_name) 
print(f"Deleted from geodatabase: {fc_name}")
    1. Place the cursor at the end of the script and press Enter twice to run the script.
  1. In the Catalog pane, click Menu and select Refresh. Optionally, right-click the file geodatabase and click Refresh.

The code block below demonstrates the full working script for multiple empty feature classes.

import arcpy

gdb = r"<gdbFolderPath>"
arcpy.env.workspace = gdb

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.activeMap

for fc in arcpy.ListFeatureClasses():
if int(arcpy.management.GetCount(fc)[0]) == 0:
for lyr in m.listLayers():
if lyr.name == fc:
m.removeLayer(lyr)
print(f"Removed from map: {fc}")

arcpy.management.Delete(fc)
print(f"Deleted from geodatabase: {fc}")

Below is the updated Catalog pane after the empty feature classes are deleted.

The updated Catalog pane

Article ID: 000042574

Software:
  • ArcGIS Pro

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options