Path and pathnameA path is a slash-separated list of directory names followed by either a directory name or a file name. A directory is the same as a system folder.
E:\Data\MyStuff (path terminating in a directory name) E:\Data\MyStuff\roads.shp (path terminating in a file name)
NOTE: In everyday usage, path and pathname are synonymous. Pathname is sometimes spelled path name.
System versus catalog pathArcGIS uses the term catalog path or ArcCatalog path. A catalog path is a pathname that only ArcGIS recognizes. For example:
refers to the powerlines feature class found in the EastValley feature dataset in the personal geodatabase Infrastructure. This is not a valid system path as far as the Windows operating system is concerned, since Infrastructure.mdb is a file, not a folder, and Windows doesn't know about feature datasets or feature classes. Of course, everything in ArcGIS knows how to deal with catalog paths.
Workspace and base nameCatalog paths consist of two parts: the workspace and the base name, as illustrated below:
LocationLocation is a catch-all term for pathname, as in: "Browse to the location of your data" or "Enter the location of your data".
Forward versus backward slashesThe Windows convention is to use a backward slash (\) as the separator in a path. UNIX systems use a forward-slash (/). Throughout ArcGIS, it doesn't matter whether you use a forward or backward slash in your path. When using the UNIX operating system, you must use a forward slash. ArcGIS will always translate forward and backward slashes to the appropriate operating system convention.
Backward slash in scriptingProgramming languages that have their roots in Unix and the C programming language, like Python, treat the backslash ("\") as the escape character. For example, "\n" signifies a carriage return. Since pathnames can contain backslashes, you need to prevent backslashes from being used as the escape character. The easiest way is to convert pathnames into Python rawstrings using the "r directive", as shown below. This instructs Python to ignore backslashes.
thePath = r"E:\data\teluride\newdata.gdb\slopes"
Learn more about the escape character in pathnames
Absolute, or full, pathAn absolute, or full, path begins with a drive letter followed by a colon, such as D:
Relative pathA relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double-dots are used for moving up in the hierarchy. A single dot represents the current directory itself. In the example directory structure below, assume you used Windows Explorer to navigate to D:\Data\Shapefiles\Soils. After navigating to this directory, a relative pathname will use D:\Data\Shapefiles\Soils as the current directory (until you navigate to a new directory, at which point the new directory becomes the current directory). The current directory is sometimes referred to as the root directory. If you wanted to navigate to the Landuse directory from the current directory (Soils), you could type in the following in the Windows Explorer Address edit box:
and Windows Explorer would navigate to D:\Data\Shapefiles\Landuse. A few more examples using D:\Data\Shapefiles\Landuse as the current directory are
.. (D:\Data\Shapefiles) ..\.. (D:\Data) ..\..\Final (D:\Data\Final) . (D:\Data\Shapefiles\Landuse - the current directory) .\..\Soils (D:\Data\Final\Soils) ..\..\.\Final\..\Shapefiles\.\Landuse (D:\Data\Shapefiles\Landuse)
NOTE: You cannot type relative paths (using the dot and double-dot notation) in any ArcGIS application. Nor can you use relative paths in Python scripts.
NOTE: A relative path cannot span disk drives. For example, if your current directory is D:, you cannot use relative paths to navigate to any directory on E:
NOTE: You cannot type relative paths (using the dot and double-dot notation) in any ArcGIS application. Nor can you use relative paths in Python scripts.When you create an ArcMap (or ArcScene or ArcGlobe) document, you can specify that pathnames will be stored as relative pathnames. (Absolute pathnames are the default.) To set this option, look under the File menu, click Document Properties, then click the Data Source Options button found on the lower right. This will open the Data Source Options dialog box, and you can specify whether to store absolute or relative paths. When you save the document with relative pathnames, the application converts pathnames into relative pathnames (using the dot/double-dot notation) relative to the location where you stored the document (the current directory). For example, if your document is stored in
and the data in one of your layers is
what gets stored in Newmap.mxd is
When you open Newmap.mxd again, ArcMap converts the stored relative pathname from the dot/double-dot notation back into the absolute path representation, which is displayed as the data source for a layer. This conversion is always relative to the location of the map document (the current directory).
Only pathnames on the same disk are convertedRelative pathnames cannot span disk drives. That is, if the root directory is on drive D, you cannot use relative pathnames to navigate to a directory on drive E. When you store your map document using relative pathnames, only those pathnames that are on the same drive are converted and stored. Learn more about referencing data in a map
- Data in a model
- Graphic images in a model
- Tools used in your model
- Files referenced in tool metadata and help
- Layer files used for symbology
- Compiled help files (.chm)
Only pathnames on the same disk are convertedRelative pathnames cannot span disk drives. That is, if the root directory is on drive D, you cannot use relative pathnames to navigate to a directory on drive E. When you store your model using relative pathnames, only those pathnames that are on the same drive are converted and stored.
- The script
- Datasets used for the default value property
- Files referenced in tool metadata and help
- Layer files used for the symbology property
- Compiled help files (.chm)
Only pathnames on the same disk are convertedRelative pathnames cannot span disk drives. That is, if the root directory is on drive D, you cannot use relative pathnames to navigate to a directory on drive E. When you store your script tool using relative pathnames, only those pathnames that are on the same drive are converted and stored.
Pathnames within the script are not convertedThere is no reliable way for ArcGIS to examine your script code, find all the pathnames, and convert them to relative paths. Furthermore, you cannot use the dot and double-dot notation in scripts. For example, the following will not work:
gp.addfield ("..\redlands.mdb\streets", "ref_ID", "long", "9", "#", "#", \ "refcode", "NULLABLE", "REQUIRED", "#")
because ..\redlands.mdb\streets is a relative pathname. You need to modify your script code so that you can find data relative to a known location. The one location you can easily find is the location of the script.Learn more about using the script pathname to find data
- You can move the document or toolbox anywhere on your computer and the data will be found when you reopen the document or tool.
- On most personal computers, the location of data is usually constant. That is, you typically don't move your data around much on your personal computer. In such cases, absolute pathnames are preferred.
- You can reference data on other disk drives.
- When moving a map document or toolbox, the referenced data has to move as well.
- When delivering documents, toolboxes, and data to another user, relative pathnames should be used. Otherwise, the recipient's computer must have the same directory structure as yours.
to a different disk, such as
ArcGIS will find D:\Tools\Scripts\MyScript.py and everything will work fine. If, however, you use relative paths, ArcGIS will not find the script and the tool will not work. The tool dialog will open but when you execute you'll get the error message "Script associated with this tool does not exist". You will have to open the tool's Properties and enter the correct pathname to the script. On the other hand, if you use relative pathnames, you can simply copy the folder D:\Tools anywhere on anyone's computer and everything will work. This won't work if you use absolute paths, because the recipient could copy the folder to F:\NewTools and the pathname D:\Tools\Scripts\MyScript.py won't exist on their computer.
- Relative paths cannot span disk drives.
- Absolute pathnames work best when data isn't moved, which is typical for disks on a personal computer.
- Relative pathnames work best when you're delivering documents and data to another user.
- Relative pathnames use dot/double-dot (. and ..) notation. You can enter relative pathnames with this notation in Windows Explorer or at the Windows command prompt.
- ArcGIS doesn't allow you to enter relative pathnames using dot/double-dot notation. Rather, relative pathnames are stored in the document or toolbox (once you check the Store relative pathnames option).
- Relative pathnames are relative to a current directory, which is the location of the saved document or toolbox.
\\<computer name>\<shared directory>\
followed by any number of directories and terminated with a directory or file name. For example:
The computer name is always preceded by a double backward-slash (\\). In UNC, the computer name is also known as the host name. A few rules for UNC pathnames are:
- UNC paths cannot contain a drive letter (such as D:).
- You cannot navigate to directories above the shared directory.
- The Store relative pathnames option for documents and tools has no affect on UNC pathnames.
- The protocol used to access the resource, such as http (HyperText Transfer Protocol) or ftp (File Transfer Protocol)
- The host (server) to communicate with
- The path to the file on the host
Windows Internet Explorer allows you to type "www.esri.com" in the Internet Explorer address bar, and it will add http://. It's more correct, however, to specify the protocol, such as http. Other protocols include https (Secure HyperText Transfer Protocol), ftp (File Transfer Protocol), mailto (E-mail address), and news (Usenet newsgroups), among others. In ArcGIS, you can only use URLs where permitted. In general, the user interface will tell you whether a URL is permitted or needed. In geoprocessing, URLs can be used in the Documentation Editor when creating links, or in labels within ModelBuilder. When using URLs in ArcGIS, it's recommended that you include the protocol, as in