Work with geoprocessing samples

A geoprocessing sample is a convenient method to share geoprocessing tools and workflows. A geoprocessing sample is a .zip file containing toolboxes, scripts, models, data, and supplemental files that run geoprocessing tools in ArcGIS. A geoprocessing sample can be a local .zip file on your desktop or on a network folder. Or, a geoprocessing sample can be shared and hosted in My Contents in ArcGIS Online or your ArcGIS Enterprise portal.

You and others can view and use the tools and data inside the geoprocessing sample by adding it to your ArcGIS Pro project.

Note:

Alternatively, you may consider sharing and using geoprocessing packages rather than samples. Geoprocessing packages offer similar capabilities without having to manually consolidate and zip a folder containing your toolbox and other files.

Create a geoprocessing sample

After creating custom script or model tools in a toolbox, consolidate all the necessary resources such as toolboxes, scripts, data, documents, projects, and so on, into a single folder that you can compress into a .zip file.

Note:

Ensure that script tools in your toolbox, data variables in your models, layer sources in your project, and other resources are saved with relative paths and have updated paths to the location in the consolidated folder. Otherwise, when someone is using the geoprocessing sample, these resources may need repair prior to use.

After consolidating the sample, test your models or script tools and other sample resources to ensure they are sourced correctly and that the tools are functional. Additionally, document your custom tools so that they are easy for others to use and understand.

Recommended folder structure and content

The following folder structure is recommended to consolidate all resources used by your tools. After consolidating, you will compress this folder into a .zip file to create a geoprocessing sample.

Folder nameDescription of contents

<Root folder>

This folder is the root of the geoprocessing sample and contains all of the following folders and the toolbox with the geoprocessing tools. This folder name should match the intended sample item name and the .zip file name.

ToolData

Contains all data used by your tools, including sample data. This folder typically contains geodatabases, shapefiles, rasters, projects, and layer files.

Scripts

Contains the scripts (.py files) for any script tools in the sample.

Scratch

This directory can be used for writing intermediate data in models and scratch data in scripts. It typically contains a geodatabase named scratch. Make sure that the folder or geodatabase does not contain datasets, which will make the sample file unnecessarily large.

Doc

Contains any supporting information that helps the user understand your sample, such as .pdf files or Microsoft Word documents and PowerPoint presentations.

Geoprocessing sample recommended folder structure

Create the geoprocessing sample .zip file

After consolidating your sample resources and testing that the tools are functional, create your .zip file using the following steps:

  1. In File Explorer, browse to the folder containing the root or main folder of your consolidated geoprocessing sample.
  2. Right-click the root folder and select Send to > Compressed (zipped) folder. Alternatively, use any zip or archive application of your choosing to create the .zip file.

The new .zip file will be in the current directory. If the directory is read-only, a dialog box will prompt you to create the file on your desktop or in your user directory.

Share a geoprocessing sample

Geoprocessing samples are a single .zip file that you can share by email, through a shared folder, or through a web page download. They are also a supported item type that can be uploaded and hosted in My Contents in ArcGIS Online or your ArcGIS Enterprise portal. Upload your geoprocessing sample using the following steps:

  1. In a web browser, go to arcgis.com or your ArcGIS Enterprise portal home app.
  2. Sign in using your credentials.
  3. At the top of the site, click Content.
  4. Click the New Item button.
  5. Drag your .zip file into the drop zone or click the Your device button or other buttons to select your .zip file.
  6. Click the Item Type drop-down menu and change the type to Geoprocessing Sample and click Next.
  7. Type the item title, folder, tags, and summary and click Save.

After completing these steps, you will be on the geoprocessing sample's item details page, where you can further configure and select sharing options for the item. By default, only you as the owner of the item can access and download it. Click the Share button to change the sharing level to Organization or Everyone (public) to allow others to download and use the sample.

Use a geoprocessing sample

Geoprocessing samples can include tools, code, projects, data, and other resources that may be useful for a problem you are trying to solve or your geoprocessing workflow. Depending on how you are obtaining the geoprocessing sample will determine how to use it.

  • Local .zip file
  • Hosted geoprocessing sample item

Local .zip file

To use a geoprocessing sample that was previously downloaded or copied to a folder on your machine or a network folder, use the following steps:

  1. In File Explorer, browse to the location of the .zip file.
  2. Right-click the .zip and select Extract All to extract the contents.
  3. In ArcGIS Pro, connect the extracted folder to your project.

Within the connected folder, you can see all the sample resources that are supported in catalog, including toolboxes and tools, geodatabases, and more.

Hosted geoprocessing sample item

To use a geoprocessing sample that is hosted in ArcGIS Online or your ArcGIS Enterprise portal, follow the steps below.

Note:

The following steps apply to Code Sample items as well as geoprocessing samples.

  1. Sign in and activate the portal in ArcGIS Pro.
  2. Search the portal for the geoprocessing sample item you want to use.
  3. Optionally, filter the search results to only the Item Type: Tools to make it easier to find geoprocessing samples.
  4. After finding the item you want to use, right-click it and select Add To Project.
    Hosted geoprocessing sample item with Add To Project command

Adding a hosted geoprocessing sample to your project will perform the following actions:

  • Download and extract the geoprocessing sample .zip file in the download location for the Other packages and files setting defined in download options. After extraction, the .zip file is deleted.
  • Add any toolboxes to the project's Toolboxes.
  • Add a folder connection to the root of the extracted folder.

The tools in the toolboxes that are added to your project can be found in the project's Toolboxes node, or by searching for tools in the Geoprocessing pane.