major-ai-skills
Version:
Installable agentic skills / AI agent skills (SKILL.md) for Claude Code, Cursor, Codex CLI, Gemini CLI & Antigravity - 402+ professional app, token-efficiency, and common-sense skills. SEO/GEO ready.
152 lines (118 loc) • 8.07 kB
Markdown
title: "Esri ArcGIS Pro Enterprise GIS AI Skill Guide (GPT & Codex)"
description: "Comprehensive operational skill specification for OpenAI GPT and Codex to automate, script, troubleshoot, and optimize ArcGIS Pro, ArcPy Python Toolbox (.pyt) architecture, NumPy/GeoPandas interop, and geodatabase cursors."
category: "Enterprise Geospatial Analysis & Mapping"
tags: ["arcgis-pro", "arcpy", "python-toolbox", "pyt", "gpt-codex", "geopandas-interop"]
# Esri ArcGIS Pro Enterprise GIS AI Skill Guide (GPT & Codex)
## Overview & Engine Architecture
ArcGIS Pro exposes a comprehensive Python 3 environment powered by **ArcPy**, integrating seamlessly with open data science stacks (**NumPy**, **Pandas**, **GeoPandas**, **SciPy**). GPT/Codex acts as a Principal Geospatial Software Engineer and ArcPy Tool Developer, delivering **Custom Python Toolboxes (`.pyt`)**, **high-performance `arcpy.da` data access cursor loops**, **raster map algebra scripts**, and **automated enterprise geodatabase migrations**.
### Developer Architecture & ArcPy Data Engine Stack
```
┌─────────────────────────────────────────────────────────────┐
│ ArcPy Data & Tooling Platform │
│ │
│ Data Access & Array Interop (`arcpy.da`) │
│ ├── `arcpy.da.SearchCursor` / `UpdateCursor` / `InsertCursor`│
│ ├── `arcpy.da.FeatureClassToNumPyArray` (Fast Vector Array)│
│ └── `arcpy.RasterToNumPyArray` (Direct Pixel Matrix Buffer)│
│ │
│ Extensibility & Custom Toolboxes │
│ ├── Python Toolbox Architecture (`.pyt` Class Definition) │
│ ├── Custom Geoprocessing Parameter Handlers │
│ └── ArcGIS REST API & Portal Content Management │
└─────────────────────────────────────────────────────────────┘
```
## Operational Capabilities & Agent Directives
1. **Python Toolbox (`.pyt`) Development**: Author modular Python Toolboxes implementing `getParameterInfo()`, `isLicensed()`, `updateParameters()`, and `execute()` with strict parameter validation.
2. **High-Speed Cursor Processing**: Optimize spatial queries using `arcpy.da.UpdateCursor` with explicit token fields (`SHAPE@XY`, `SHAPE@AREA`, `SHAPE@LENGTH`) rather than heavy full-geometry serialization.
3. **NumPy & Raster Array Integration**: Implement fast cellular automata and raster processing by converting rasters into NumPy arrays, executing vectorized matrix calculations, and converting back to GeoTIFFs.
4. **Spatial Database Migration Scripts**: Author scripts to convert legacy Shapefiles and KML files into structured Enterprise Geodatabase Feature Datasets with Topology Rules and Attribute Domains.
## Production Python Code: Custom Python Toolbox (`.pyt`) for Spatial Attribute Auditing
Save this script as `SpatialQualityToolbox.pyt` to load directly into the ArcGIS Pro Catalog Pane:
```python
# ==============================================================================
# ArcGIS Pro Custom Python Toolbox (.pyt): Spatial Quality & Area Auditor
# Validates vector geometry validity and updates geodesic area metrics.
# ==============================================================================
import arcpy
class Toolbox(object):
def __init__(self):
self.label = "Spatial Quality Toolbox"
self.alias = "spatialquality"
self.tools = [PolygonAreaAuditTool]
class PolygonAreaAuditTool(object):
def __init__(self):
self.label = "Audit & Calculate Geodesic Area"
self.description = "Checks geometry validity and updates calculated area in hectares."
self.canRunInBackground = False
def getParameterInfo(self):
# Parameter 0: Input Polygon Feature Class
param_in_features = arcpy.Parameter(
displayName="Input Polygon Features",
name="in_features",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input"
)
param_in_features.filter.list = ["Polygon"]
# Parameter 1: Target Area Field Name
param_field_name = arcpy.Parameter(
displayName="Target Area Field (Hectares)",
name="area_field",
datatype="GPString",
parameterType="Optional",
direction="Input"
)
param_field_name.value = "AREA_HECTARES"
return [param_in_features, param_field_name]
def isLicensed(self):
return True
def execute(self, parameters, messages):
in_features = parameters[0].valueAsText
field_name = parameters[1].valueAsText
messages.addMessage(f"Processing feature class: {in_features}...")
# 1. Repair Invalid Geometry
messages.addMessage("Running Repair Geometry...")
arcpy.management.RepairGeometry(in_features, "DELETE_NULL")
# 2. Add Field if not exists
fields = [f.name for f in arcpy.ListFields(in_features)]
if field_name not in fields:
messages.addMessage(f"Adding new field '{field_name}' (DOUBLE)...")
arcpy.management.AddField(in_features, field_name, "DOUBLE")
# 3. Calculate Geodesic Area via Data Access UpdateCursor
count = 0
with arcpy.da.UpdateCursor(in_features, ["SHAPE@AREA", field_name]) as cursor:
for row in cursor:
# Square meters to hectares (1 ha = 10,000 sq m)
area_sqm = row[0]
area_ha = area_sqm / 10000.0
row[1] = area_ha
cursor.updateRow(row)
count += 1
messages.addMessage(f"✅ Successfully updated {count} feature records with geodesic area.")
```
## Technical Troubleshooting Matrix
| Issue & Failure Signature | Root Cause Analysis | Diagnostic & Resolution Pathway |
| :--- | :--- | :--- |
| **`RuntimeError: Object: CreateObject cannot create cursor`** | Target feature class is exclusively locked by another process or field name in cursor is misspelled. | 1. Verify field names using `[f.name for f in arcpy.ListFields(fc)]`.<br>2. Close open attribute tables in ArcGIS Pro GUI. |
| **`arcpy.da.FeatureClassToNumPyArray` Memory Error** | Attempting to load millions of heavy multi-part polygons into system RAM simultaneously. | Filter features with a `where_clause` or pass specific required numerical attribute fields rather than geometry shapes. |
| **Python Toolbox (.pyt) Not Appearing in Pro Catalog** | Python syntax error in class declaration or missing required method (`getParameterInfo()`). | Test `.pyt` syntax using standard Python interpreter: `python -m py_compile MyToolbox.pyt`. |
| **Field Calculation Returns NULL for All Rows** | Calculation attempted with incompatible data type (e.g. assigning string to integer field). | Inspect field data type via `arcpy.Describe(fc).fields`. |
## Command Line Syntax & Batch Processing
```bash
# Execute ArcPy Script in Pro Environment
propy.bat "C:\Scripts\batch_reproject.py"
# Launch Headless Python Console for Pro
"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe"
```
### Essential File Locations
- **Custom Toolboxes**: `*.pyt`
- **ArcPy Environment Config**: `C:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat`
## Agent Operational Directive
> **MANDATORY**: Always use `arcpy.da.SearchCursor` and `UpdateCursor` with context managers (`with ... as cursor:`) to ensure database locks are released immediately upon completion.