This video details using Chat GPT, ArcGIS Pro, and Python to boost productivity within ArcGIS Pro. Specifically we will be subsetting a large data set and getting the SQL query data for that large query. Trying to do this by hand could be tedious but with a few lines of python you can get it done quick. Stay tuned for more ways to use Chat GPT for GIS.
Thanks for watching! Please like, subscribe, and comment below with any questions.
Table of Contents
00:00 – Intro
01:12 – Asking Chat GPT about a python script
01:47 – Copying code from Chat GPT
02:02 – Opening Python Notebook in ArcGIS Pro and pasting code in
02:15 – Break Down of GPT code line by line and creating query
04:22 – Printing the Query data to use in Definition Query and Select By Attributes
04:53 – Creating Definition query from query we just created
05:16 – Removing Definition Query
05:25 – Selecting by attributes with the query we just created
06:01 – Outro
Code:
import arcpy
Set the workspace and table
table = "'YourTable'"
Get unique IDs
unique_ids = set(row[0] for row in arcpy.da.SearchCursor(table, "YourField"))
Construct the query
query = " OR ".join(f'YourField = {id}' for id in unique_ids)
Apply the query
print(query)