Show Navigation | Hide Navigation
You are here:
Geoprocessing > Automating your work with scripts > Accessing tools within a geoprocessing script

Setting paths to data

Release 9.3
Last modified June 3, 2010
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Accessing tools within a geoprocessing script"


Note: This topic was updated for 9.3.1.

When the path to a dataset is specified as a tool or environment setting parameter, it must be the same as the path reported on the ArcCatalog Location toolbar. Tools use ArcCatalog to find geographic data using an ArcCatalog path. This path is a string and is typically unique to each dataset, containing either its folder location, database connection, or URL in the case of streaming Internet map server (IMS) or server data. If the dataset you want to use as a tool parameter cannot be seen in ArcCatalog, then it cannot be used except for some file-specific parameters such as an ArcInfo interchange file (e00) or raster color map file.

The ArcCatalog path for a shapefile is simply the path to the folder containing the shapefile and the shapefile's name including its .shp extension. A shapefile containing roads located in the folder C:\GrosMorne would have an ArcCatalog path of C:\GrosMorne\roads.shp. A coverage in that same folder containing a study area polygon would have a similar ArcCatalog path of C:\GrosMorne\StudyArea. A shapefile's extension is used to differentiate between a shapefile and a coverage having the same name in the same folder. INFO and dBASE tables act the same way, except the dBASE table has a .dbf extension.

Feature classes in a personal geodatabase reside in an Access database file, feature classes in a file geodatabase reside in a file system folder, and enterprise geodatabase feature classes are found in a relational database management system (RDBMS). The ArcCatalog path to a personal geodatabase has the disk location of the Access file, and the path to a file geodatabase path is the disk location of the file system folder. A feature class name is simply added to the path if it is stand–alone, resulting, for example, in a path of C:\GrosMorne\Data.gdb\rivers. If a feature class is contained by a feature dataset, the feature dataset's name must precede the feature class name. Feature class paths must always include the feature dataset name when applicable; otherwise, a tool does not recognize the path.

Instead of a path to a personal or file geodatabase, paths to data in an enterprise geodatabase contain the location of the file defining the database connection. The default location for this information is Database Connections in ArcCatalog, so a typical path to a stand-alone feature class in an enterprise geodatabase may appear as Database Connections\Connection to GrosMorne.sde\reed.roads. Use the Location toolbar in ArcCatalog to check a dataset or workspace path.

Learn more about complex parameters


Using paths in Python


A backslash (\) is a reserved character indicating line continuation or an escape sequence in Python. For instance, \n represents a line feed, \t represents a tab.
When specifying a path, a forward slash (/) can be used in place of a backslash. Two backslashes can be used instead of one to avoid a syntax error. A string literal can also be used by placing the letter r before a string containing a backslash so it is interpreted correctly. All examples in the Automating your work with scripts section of this help system use forward slashes.

Example 1: Valid use of paths in Python

gp.getcount("c:/temp/streams.shp")
gp.getcount("c:\\temp\\streams.shp")
gp.getcount(r"c:\temp\streams.shp")


Example 2: Invalid use of paths in Python

gp.getcount("c:\temp\streams.shp")


Failed to execute. Parameters are not valid.
Input Rows: Dataset c:	emp\streams.shp does not exist
Failed to execute (GetCount).



Tips



Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.