ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS 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
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Exists

  • Summary
  • Discussion
  • Syntax
  • Code sample

Summary

Determines the existence of the specified data object. This function tests for the existence of various data types including feature classes, tables, datasets, shapefiles, workspaces, layers, and files. The function returns a Boolean indicating whether the element exists.

Discussion

Layers in a stand-alone script and layers in an active map can be used as input to Exists.

Syntax

Exists (dataset)
ParameterExplanationData Type
dataset

The path to the dataset to be checked for existence.

String

Return Value

Data TypeExplanation
Boolean

A Boolean value of True will be returned if the specified element exists.

Code sample

Exists example

Check for the existence of specified data object.

import arcpy

# Set the current workspace
arcpy.env.workspace = "c:/base/data.gdb"

# Check for existence of data before deleting
if arcpy.Exists("roadbuffer"):
    arcpy.Delete_management("roadbuffer")

Related topics

  • Checking for the existence of data

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal