1

I am new to python and trying to create a script that will select specific parcels from a large parcel layer. Is it possible to create a dictionary with the names of the parcels as the key and the query used to find the parcels as the value and input those into a arcpy.Select_analysis with a for loop to loop through the dictionary? What would be the best way to set this up?

example

Import arcpy
import os  #importing operating system functions
arcpy.env.workspace = "c:\gis\python\other\parcels.gdb"
arcpy.env.overwriteOutput = True

properties{'johns pizza':"MUN in ('1323') and BLOCK in ('168') and LOT in ('20')",'chinese palace':"MUN in ('1326') and BLOCK in ('12') and LOT in ('100')"}`

for key in properties:
    arcpy.Select_analysis("parcels", key, value) 
  • 1
    Learn how to loop over dictionaries in Python. stackoverflow is the place to look: stackoverflow.com/questions/3294889/… – RoVo Mar 26 '18 at 14:17
  • That workflow seems unnecessary. Why not simply apply the SQL expression in the Select_analysis() tool? – Aaron Mar 28 '18 at 0:08
1

If you look at the syntax section of the Select tool it explains the parameters of the tool. Parameter 2 is the output feature class (what is you KEY from your dictionary) and parameter 3 is the where clause (what is value from your dictionary).

Your output featureclass name is invalid for a geodatabase, it cannot have spaces in it. Suggest you read this Defining FeatureClass properties page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.