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.

Alright another problem that I have. I am trying to give a priority ranking to lots based on various criteria. Basically I have 7 areas that are criteria, if lots overlap each other the criteria is added up and given a sum value (so the highest number could be 7). Now I am trying to create a python script that basically goes through my criteria and adds a value to a field added to an attribute table

For example, I would do a select by location for lots that are within 30m of wetlands - if YES then the field "CRITERIA" would be given a 1, if no it would be a 0 this same selection idea would be done for the rest of my criteria - then what I need is to have it total up the 1's that are in each row into a separate "RANKING" field.

share|improve this question
    
How far have you gotten? Presumably you are looking for help with something but there is no actual question posed yet. –  blah238 Apr 19 '12 at 23:43
    
I looked for a question mark in the "question" too. Ideally, I think a Question should have one (and only one) question mark to highlight what is being asked. –  PolyGeo Apr 20 '12 at 0:14

1 Answer 1

If you select features in a layer, Field Calculator will only run on the selected features. So here's what I would do:

#Names of layers in table of contents
Lots_lyr = "Lots"
CriteriaList = ["Criterion1","Criterion2","Criterion3","Criterion4","Criterion5","Criterion6","Criterion7"]

#Add field that contains the sum of criteria
arcpy.AddField_management(Lots_lyr,"CriteriaSum","SHORT")

#Loop through 7 criteria layers
for Criterion in CriteriaList:

    #Select lots within range
    arcpy.SelectLayerByLocation_management(Lots_lyr,"WITHIN_A_DISTANCE",Criterion,"30 meters")

    #Increment sum for selected lots via field calculator
    arcpy.CalculateField_management(Lots_lyr,"CriteriaSum","!CriteriaSum! + 1","PYTHON")

Note: I have not tested this myself

share|improve this answer
1  
Instead of using a range, you can iterate directly over lists, i.e. for criteriaLayer in CriteriaList and criteriaLayer instead of CriteriaList[i]. If you need a running count use for i, criteriaLayer in enumerate(CriteriaList). –  blah238 Apr 20 '12 at 3:34
    
Good point--I don't know why I didn't do that in the first place! –  dmahr Apr 20 '12 at 3:59

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.