Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to get a script running much faster than it is now. The script completes on my machine in about 33 minutes. It generates a report that counts features with specific attributes in one field. What I think is generally the problem to be solved is that there are 7 features classes in 70+ datasets, with 4 possible entries in the field that I want counted separately.

Here is a very reduced and plain version of the code, it shows generally the structure of the nested cursor in some nested for loops. I wonder if it is possible to NOT have the cursor creation be this nested??

state_plane_list = [...]
feature_class_list = ['PRCL_POL_',...]
clause = ["RESEARCH_STATUS = 'NULL'",...]

for state_plane in state_plane_list:
     for feature_class in feature_class_list:
          for rstatus in clause:
               cursor = arcpy.da.SearchCursor(feature_class + state_plane, fields, str(rstatus))  
                       ***Counting code here - everything ends up in a dictionary and eventually gets written to a csv using DictWriter() ****

Basically, is there another...hopefully more efficient... way to do this?? I feel like creating 1600+ cursor objects may be way too dense a procedure.

share|improve this question

migrated from stackoverflow.com Nov 4 '13 at 5:38

This question came from our site for professional and enthusiast programmers.

1 Answer 1

At the moment you are searching your entire dataset for each combination. You would probably find it quicker to use a view of state_plane, from that create a view of feature_class_list, etc.

N.B. View might be the wrong terminology for this database - it's been a while since my DB centric work - look at creating a query that creates a subset to search.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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