Monday, 16 January 2017

field calculator - Counting occurrences across a record in ArcGIS 10.0


I'm a student at Millersville University, PA studying for a BA in Geography with a concentration in GIS. I've stumbled across this site for questions I've had over the past year or so with getting introduced to ArcGIS. So thank you all here for helping a student out :)


I have come across a problem that I can't figure out and my textbook didn't offer any help so I'm hoping one of you can.


I have a table which consists of 3 attribute joins, and I have a text field which has 2 unique values. I want to create a field in which I can summarize the number of times a particular text occurs.


For Example: Jx = Join #


ObjectID 1 |J1: A | J2: A | J3: B | CountFldA: 2
ObjectID 2 |J1: B | J2: B | J3: A | CountFldA: 1

I have a feeling that the answer lies somewhere in python but I have no formal experience in it.



Answer




You could concatenate multiple fields together into a new combined field and use 'InStr' inside the Field Calculator (VBScript) to count the number of occurrences of a specific character or string. For example, instr([Combined],"A") would return the number of "A"s in the Combined field. Or I suppose you could use InStr on each individual joined field and then add them up. instr([Field1],"A") + instr([Field2,"A") and so on.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...