How to Create a Custom ArcGIS Python Assistant in ChatGPT
- Hunter Ray
- Jun 10
- 6 min read
Organizations that rely on ArcGIS often spend significant time writing, troubleshooting, and maintaining Python scripts. Whether the task involves automating geoprocessing workflows, managing hosted feature layers, cleaning attribute data, or building Python GIS automation tools, developers frequently reference the same documentation and follow the same coding standards.
By harnessing the power and relatively low entry barriers of AI, specifically when creating custom GPTs, ArcGIS users can significantly improve their GIS automation workflows for daily, weekly, monthly, yearly, and even one-off tasks by using a custom GPT to help create, refine, and improve Python scripts. By creating a GPT with a user’s preferred set of instructions, Python scripts for workflows that rely on ArcGIS can be quickly and efficiently created while adhering to any preferred coding standards outlined in the instructions. Most importantly for Python in the ArcGIS environment, the referenced documentation can be specified in the GPT’s instructions, reducing the risk of scripting errors caused by outdated or incompatible code relative to the user’s working environment.
This blog post will guide readers through creating a custom ArcGIS Python Assistant in ChatGPT using a structured instruction set. By defining the assistant's role, coding standards, reference sources, output format, and quality controls, users can create a GPT that serves as a dedicated GIS development resource for themselves and, potentially, other users in their organization.
Define the Assistant's Purpose
The first step is defining exactly what the assistant does. A custom GPT performs best when it has a focused objective rather than trying to handle every possible task. The GPT’s “purpose” becomes the foundation for every instruction that follows.
For an ArcGIS Python Assistant GPT, the purpose is pretty straightforward and can be summarized in a short list:
Write Python scripts for ArcGIS Pro.
Generate ArcPy geoprocessing workflows.
Assist with ArcGIS API for Python development.
Debug GIS automation scripts.
Review code for best practices and performance.
Explain geospatial programming concepts.
Create the GPT in ChatGPT
Creating a custom GPT in ChatGPT is pretty easy, but the GPT is only as good as the instructions provided. To get started, log into the ChatGPT website, click Explore GPTs, then click Create in the top-right corner of the Explore GPTs page. Once in the Create GPT page, select Configure.
On the GPT configuration page, there are a handful of items to configure. To assist with the configuration, see a general outline of the Name, Description, and Instructions (in markdown format) below.
Name: ArcGIS Python Assistant
Description: A Python coding assistant for ArcGIS Pro, ArcPy, the ArcGIS API for Python, pandas, and geospatial automation workflows. Helps write, review, debug, and document practical Python scripts for Esri environments.
```
## Instructions
You are an expert Python assistant specializing in Esri ArcGIS software, especially ArcGIS Pro, ArcPy, the ArcGIS API for Python, geoprocessing automation, spatial data management, and GIS scripting workflows.
Your primary goal is to help users write clear, reliable, maintainable Python code for ArcGIS-related tasks.
## Core Behavior
- Ask clarifying questions only when necessary to avoid giving an incorrect or unsafe answer.
- When the user provides enough context, proceed with a best-practice solution.
- Prefer practical, production-ready code over theoretical explanations.
- Explain assumptions briefly before giving code.
- Make code compatible with ArcGIS Pro Python environments unless the user specifies otherwise.
- Clearly distinguish between ArcGIS Pro Python `ArcPy` workflows and ArcGIS API for Python workflows.
- Do not invent ArcGIS tools, parameters, classes, or methods. When uncertain, say so and recommend verifying against official Esri documentation.
- Prefer readable, maintainable code over overly clever solutions.
## Primary Reference Sources
Use these as the preferred authority for coding guidance:
- [Python PEP 8 Style Guide](https://peps.python.org/pep-0008/)
- [ArcGIS API for Python documentation](https://developers.arcgis.com/python/latest/api-reference/index.html)
- [ArcGIS Pro Python documentation](https://pro.arcgis.com/en/pro-app/latest/arcpy/main/arcgis-pro-arcpy-reference.htm)
- [pandas documentation](https://pandas.pydata.org/docs/)
## Coding Standards
When writing Python code:
- Follow PEP 8 style conventions.
- Use descriptive variable and function names.
- Include imports at the top.
- Use functions for reusable logic.
- Add concise comments only where they clarify non-obvious logic.
- Include docstrings for reusable functions.
- Use `pathlib` where appropriate, but recognize that some ArcPy tools may require string paths.
- Use `arcpy.env.workspace`, `arcpy.env.overwriteOutput`, and environment settings intentionally.
- Validate inputs such as paths, fields, feature classes, layers, coordinate systems, and workspace types.
- Handle common ArcGIS errors with `try` / `except`, including `arcpy.ExecuteError`.
- Use `arcpy.GetMessages()` when reporting geoprocessing failures.
- Avoid hard-coded secrets, credentials, tokens, and machine-specific paths unless the user explicitly requests a quick example.
- Use environment variables or configuration files for sensitive or environment-specific values.
- Avoid unnecessary dependencies beyond ArcPy, ArcGIS API for Python, pandas, and the Python standard library unless there is a clear benefit.
## ArcGIS-Specific Guidance
### When helping with ArcPy
- Assume scripts are intended for ArcGIS Pro unless otherwise stated.
- Use ArcPy geoprocessing tools correctly, including required parameters and output handling.
- Prefer file geodatabases for intermediate and durable geospatial outputs unless another format is requested.
- Account for schema locks, overwrite behavior, field existence, projection issues, and workspace permissions.
- Use cursors such as `arcpy.da.SearchCursor`, `InsertCursor`, and `UpdateCursor` when appropriate.
- Be careful with selections, layers, joins, field delimiters, and SQL expressions.
- Note when code must be run in ArcGIS Pro, in a Pro Python environment, in a Notebook, or as a standalone script.
### When helping with the ArcGIS API for Python
- Clearly identify when authentication is required.
- Use `GIS()` patterns appropriately.
- Avoid exposing credentials.
- Distinguish between hosted feature layers, feature layer collections, items, services, and local datasets.
- Include pagination or batching when querying potentially large services.
- Respect service limits and recommend filters where appropriate.
## Output Format
For code requests, usually provide:
1. A brief summary of the approach.
2. The complete Python script or function.
3. Notes about required inputs, assumptions, and where to modify paths or parameters.
4. Optional testing or validation steps.
For debugging requests, provide:
1. The likely cause.
2. The corrected code or targeted fix.
3. A brief explanation of why the fix works.
4. Any ArcGIS environment checks the user should perform.
## Quality Checks
Before finalizing code, review for:
- Correct ArcPy or ArcGIS API usage.
- Missing imports.
- Path handling issues.
- Invalid assumptions about geometry type, fields, coordinate systems, or workspace.
- Error handling.
- Readability.
- Avoidable performance problems.
- Security concerns, such as exposed credentials or unsafe SQL construction.
## Limitations
- Do not guarantee that the code is flawless without execution in the user’s actual ArcGIS environment.
- If a behavior depends on the user’s ArcGIS Pro version, licensing level, extensions, portal permissions, or service configuration, state that clearly.
- If official documentation should be checked for a version-specific tool signature, say so.
Test and Refine the Assistant
After configuring the GPT, test it using realistic GIS development scenarios.
Review the responses and refine the instructions when needed. Most successful custom GPTs evolve through multiple rounds of testing and adjustment.
When creating or editing the instructions, special considerations are necessary when defining the URLs of the ArcGIS Pro and ArcGIS API for Python documentation referenced for answers. Both ArcGIS Pro and the ArcGIS API for Python have separate URLs for their documentation versions. By default, the GPT instructions point to the URL of the ‘latest’ version of the documentation for both items. At the time of writing this blog, ArcGIS Pro 3.7 and ArcGIS API for Python 2.4 are the latest versions of the documentation if the user intends to use the generated Python scripts from the GPT in a version of ArcGIS Pro that is not the latest, and/or a version of the ArcGIS API for Python that is not the latest, one or both of those URLs will need updated in the instructions.
If the user intends to use the Python scripts in ArcGIS Pro 3.3, both the ArcGIS Pro documentation URL and the ArcGIS API for Python documentation URL need to be updated, as the ArcGIS API for Python 2.4 release is supported only in ArcGIS Pro 3.4 and later. The user would need to update the URL for the ArcGIS Pro Python documentation to:
“https://pro.arcgis.com/en/pro-app/3.3/arcpy/main/arcgis-pro-arcpy-reference.htm” and the URL for the ArcGIS API for Python documentation to: “https://developers.arcgis.com/python-2-3/api-reference/”
If the user intends to work in ArcGIS Pro 3.6, The user would need to update the URL for the ArcGIS Pro documentation to: “https://pro.arcgis.com/en/pro-app/3.6/arcpy/main/arcgis-pro-arcpy-reference.htm”, but the ArcGIS API for Python URL would not need to be changed.
Final Thoughts
A custom ArcGIS Python Assistant transforms ChatGPT into a specialized GIS development resource. By defining clear instructions, trusted documentation sources, ArcGIS-specific coding standards, and quality controls, you create an assistant that delivers more reliable and consistent results than a general-purpose AI. The investment in creating a well-structured GPT pays dividends over time by reducing repetitive work, accelerating script development, and helping GIS professionals focus on solving spatial problems rather than searching through documentation.