Show Navigation | Hide Navigation
You are here:
Geoprocessing > Sharing tools and toolboxes

Pathnames explained: Absolute, relative, UNC, and URL

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

Print all topics in : "Sharing tools and toolboxes"


Related Topics

You deal with pathnames every day to browse to your data and toolboxes. You probably don't give them much thought, nor do you need to until it comes time to share your data and tools. This section delves into detail about paths, defining the different types and how ArcGIS manages them. Subsequent topics on sharing tools assume that you've reviewed the material presented here.


Paths and pathnames


Path and pathname


A 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 path


ArcGIS uses the term catalog path or ArcCatalog path. A catalog path is a pathname that only ArcGIS recognizes. Here is an example:

D:\Data\Final\Infrastructure.mdb\EastValley\powerlines


The code above refers to the power lines 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 name


Catalog paths consist of two parts: the workspace and the base name, as illustrated below

Dataset name

Location


Location 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 slashes


The 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 scripting


Programming 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 and relative pathnames



Absolute, or full, path


An absolute, or full, path begins with a drive letter followed by a:, such as "D:"

Relative path



A 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.

Example directory structure

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:

..\Landuse


Windows Explorer would navigate to D:\Data\Shapefiles\Landuse. A few more examples using D:\Data\Shapefiles\Landuse as the current directory are the following:

..               (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:.




Absolute and relative pathnames in ArcMap


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.

Absolute versus 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

D:\Maps\Posters\Newmap.mxd


and the data in one of your layers is

D:\Data\Final\Infrastructure.gdb\Streets


what gets stored in Newmap.mxd is

..\..\Data\Final\Infrastructure.gdb\Streets


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 converted


Relative 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


Absolute and relative paths in model tools


Just like data in ArcMap, you can specify that pathnames in your model tools will be stored as relative paths.
The current directory used for relative paths is the directory where the tool's toolbox resides. The relative pathname option converts and stores pathnames to the following:



To store as relative paths, right-click the model tool, click Properties, and click the General tab. At the bottom of the dialog box, check Store relative pathnames (instead of absolute paths), as shown below.

Relative pathnames in model tools

Only pathnames on the same disk are converted


Relative 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.


Absolute and relative paths in script tools


When using the Add Script wizard, the option to store relative path names will appear on the first panel. You can also set this option by right-clicking the script tool, clicking Properties, and clicking the General tab. At the bottom of the dialog box, check Store relative path names (instead of absolute paths).

The current directory used for relative paths is the directory where the tool's toolbox resides. The relative pathname option converts and stores pathnames to the following:



Only pathnames on the same disk are converted


Relative 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 converted


There 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


Why use relative versus absolute pathnames?

Using absolute pathnames



Using relative pathnames


For example, consider the directory structure below. In this example, D:\Tools\Toolboxes\Toolbox1 contains a script tool that uses D:\Tools\Scripts\MyScript.py.

Example structure

Using absolute paths, if you moved the toolbox from
    D:\Tools\Toolboxes\Toolbox1

to a different disk, such as
    E:\Final\Toolbox1


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.

Summary






UNC pathnames


UNC stands for Universal (or Uniform, or Unified) Naming Convention and is a syntax for accessing folders and files on a network of computers. The syntax is

\\<computer name>\<shared directory>\

followed by any number of directories and terminated with a directory or file name.

For example:
\\pondermatic\public\studyarea.gdb
\\omnipotent\shared_stuff\wednesday\tools


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 ar the followinge:


In ArcGIS, you can use a UNC pathname anywhere a pathname is requested. This is particularly advantageous for shared data on a local area network (LAN). Data can be stored on one computer and everyone with access to the computer can use the data as long as the computer is not turned off or removed from the network.

In Windows, you can share a folder so that other users on your local area network can access it. In ArcCatalog or Windows Explorer, right-click a folder, click Sharing and Security, then follow the instructions on the dialog box that opens.


URLs


URL stands for Uniform Resource Locator and uniquely specifies the address of any document on the Internet. The components of a URL are



Below is an example:
http://www.esri.com/products.html


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).

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 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

http://www.esri.com


rather than

www.esri.com


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