2

My goal is to isolate the ID#s observed in Zone C and only Zone C (like IDs 2236 and 3007 in the attached table). There are records for which the same ID was observed in other zones besides Zone C, or was observed multiple times in Zone C.

How can I extract only those individuals who were observed in C and ONLY in C? Selecting by location is not what I need because some of the ID#s in C are also in other zones. I have tried Select by Attribute and the Dissolve tool but I am not quite getting the right combination. Can someone point me in the right direction? I am using ArcGIS Desktop 10.4.

clip of attribute table

3

I have a solution via the Field Calculator and a short python code.

  1. First add a Field to your Table (in my example it is named test).
  2. Next open the Field Calculator for your new Field.

    enter image description here

  3. There you have to mark Python at the top and check the Show Codeblock

  4. In the Codeblock/Pre Logic Script Code you post this Python Script(you must only edit "your_layer_name" and maybe the field name directly behind it):

list = [ ] cursor = arcpy.da.SearchCursor("your_layer_name", ["ID#", "Zone"]) for row in cursor: if row[1] != "C": list.append(row[0]) def calc(id): global list if id in list: return( 0) else: return(1)

  1. In the lower box you write the following (change ID# to the name of your id field): calc(!ID#!)
  2. Now you can click on Ok. Every ID#, which has only Zone C has a 1 and every other row has now 0 in Field test.

    enter image description here

  3. Just do now a Select by Attributes with test = 1

Hope this can help, if you have questions just ask.

  • Thank you! However, I am sure your solution is correct but it is failing to execute on my end. I am getting a syntax error: "Parsing error IndentationError: unexpected indent (line 3)" – surveyor Jan 29 at 16:19
  • I edited my post, it seems i made a mistake at the moment i copied the script. – Tim Jan 29 at 16:30

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.