Having the code below im trying to select all the table features from an school_enroll.shp that are within each bigger zones from the hs_bndy.shpwhen i use the arcpy.SelectLayerByLocation_management for some reason the selection isn't happening. Am i doing something wrong here? I like to be able to sum some of the fields from the selected school_enroll.shp features

fields = {i:str(field.baseName) for i,field in enumerate(input)}
input = arcpy.ListFields("HS_Bndy1516.shp")
school_ampa = "C:/school_enroll.shp"
rows = arcpy.UpdateCursor("HS_Bndy1516.shp")

for row in rows:
    total = 0
    row_name =  row.getValue("NAME")
    sql = "{} = '{}'".format(fields[3], row_name)
    arcpy.MakeFeatureLayer_management("HS_Bndy1516.shp", 'school_lyr', sql)
    with arcpy.da.SearchCursor('school_lyr',"HSadd")as cursor:
        for row in cursor:
            total = row[0] + total  

Your Answer

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

Browse other questions tagged or ask your own question.