Hi,
is there an equivalent to the "Find tool" in ArcMap using arcpy? The find tool is way faster when searching over multiple layers than any code I can come up with... Any ideas?
Thanks to all of you, there are a number of interesting points to check now. Thankfully first I will be off to the mountains for a week or so and will tackle that problem when I'm back
Ensure the field you are querying over has an attribute index built for it.
Are you sure the slowness is coming from ListFeatureClasses()? If so, maybe try arcpy.da.Walk()
If not, it might be the counting of records that's slow. @JoshuaBixby posted a blog article a while back concerning the performance of counting records. Unfortunately, the formatting was lost in transition to the new Geonet forum but he summarizes in the comments that:
If you can reach back to the layer, feature layer, feature class, table view, or table; then the Get Count tool is by far the quickest method.
However, it does look like you're applying a where_clause so you'd probably have to make a selection first for get count, which would likely negate the performance gain. Maybe try ArcSDESQLExecute() with a where clause and count?
I thought so [sigh...]
I am using a two-step approach:first selecting feature classes based on name and then looping through the list with a search cursor:
fcList = arcpy.ListFeatureClasses(sSearchStr,"POLYGON")
for fcls in fcList:
cnt = len([r[0] for r in arcpy.da.SearchCursor(fcls, fieldname, where_clause = query)]) if cnt > 0:
[....]
Would be great if you have an idea how to speed up this process!
There is no equivalent in arcpy.
If you don't know the exact name or position, I can't think of another way than simply looping over everything that's there and checking for likeness. There may be some inefficiency in your code that could be improved. Feel free to post a snippet of what you're doing.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.