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

Pathnames explained: Absolute, relative, UNC, and URL

Release 9.2
Last modified November 9, 2007
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 pathnames, defining the different types and how ArcGIS manages them. Subsequent topics on sharing tools assume that you've reviewed the material presented here.

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.



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 Windows and 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.

System versus catalog path


In ArcGIS, you'll sometimes come across the term catalog path or ArcCatalog path. A catalog path is a pathname that only ArcGIS recognizes. For example:

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


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.


Absolute and relative pathnames



Absolute, or full, path


An absolute, or full, path begins with a drive letter followed by a colon, 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

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



You cannot enter relative pathnames using the dot/double-dot notation described above in any ArcGIS desktop application. However, 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 all pathnames into relative pathnames (using the dot/double-dot notation) in relation to the location where you stored the document. 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. Note, however, that if you move Newmap.mxd to another directory, the data will not be found.

Learn more about referencing data in a map

Absolute and relative paths in geoprocessing tools



Just like data in ArcMap, you can specify that pathnames in your tools are to 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 paths to


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

Relative pathnames in tools

When you add a script tool, this option will also appear on the first panel of the Add Script wizard. Setting this option on the Add Script wizard is the same as setting it on the tool's property dialog box, so you can always reset this option when the Add Script wizard is completed.

Setting relative paths in the script wizard

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. At the same time, you should probably uncheck the Store relative pathname option.
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 are


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) or wide area network (WAN). Data can be stored on one computer and everyone with access to the computer can use the data.
There are two issues with sending documents or tools that contain UNC paths.



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:



For 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), 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

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.