arcpy-scriptinglisted
Install: claude install-skill wiatrek-kevin-s/columbus
# ArcPy scripting
ArcPy is ArcGIS Pro's Python package. It runs geoprocessing tools, reads and writes data
with cursors, and edits geodatabases. Scripts fail mostly for boring reasons: the wrong
Python, a missing licence, a lock, a path, or editing versioned data outside an edit session.
## General practice (with or without Columbus)
### 1. Run it in the right Python
- Pro ships a conda environment, **`arcgispro-py3`**, which is read-only. Never `pip install`
into it.
- To add packages, **clone it**: Pro > Settings > Package Manager > Environment Manager >
Clone, or from the "Python Command Prompt":
```bat
conda create --clone arcgispro-py3 --name gis-py3
proswap gis-py3
```
`proswap` makes the clone Pro's active environment. Then `conda install` (preferably from
Esri's channel) into the clone.
- Run scripts outside Pro with the active environment through `propy.bat`:
```bat
"C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\propy.bat" C:\work\fix_roads.py
```
- After a Pro upgrade, re-clone. Old clones keep the old ArcPy and break in odd ways.
- ArcPy is Python 3, 64-bit. ArcMap's Python 2.7 `arcpy.mapping` scripts do not run;
`arcpy.mp` replaced it.
### 2. Script skeleton
```python
import arcpy
arcpy.env.workspace = r"C:\work\roads.gdb"
arcpy.env.overwriteOutput = True # else ERROR 000725 on rerun
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(2277) # NAD83 / Texas Central (ftUS)
arcpy.env.geographicTransformatio