Select to view content in your preferred language

Copy only id of points which has minimum value within group in ArcGIS

769
5
12-29-2019 01:17 AM
Kapil_DevAdhikari
Emerging Contributor

I have points shape file with multiple attribute fields, as below:

Attribute table sample

In above attribute:
'FID_Net' is 'unique value/subset' and 'class' is the 'value'. And in my new data sheet, the values of column 'class' is not repeating. I have to copy that unique value 'FID_Net' to new field 'New_FID' of only one row which value 'class' is minimum within group 'FID_Net' and rest of others row should be 0 or NULL as in my paper's table (Expected).

rough sketch flow:

Tags (1)
0 Kudos
5 Replies
JimCousins
MVP Regular Contributor

A few comments:

You need to use a variable to return the value, not the column name itself

You need and End If at the end of your code

After the Else statement, you need to also use the same variable to return the 0 value

I am assuming that you are using the code block for the field calculation.

set the Expression  = result

in the code block (I created fields from your table snapshot)

If [species] = "Pinus" and [class1] = 1 and [condition] ="G" then
result = [ITID]
elseif [species] = "Pinus" and [class1] = 1 and [condition] ="M" then
result = [ITID]
elseif [species] = "Pinus" and [class1] = 2 and [condition] ="G" then
result = [ITID]
elseif [species] = "Pinus" and [class1] = 2 and [condition] ="M" then
result = [ITID]
Else
result = 0
End if

Kapil_DevAdhikari
Emerging Contributor

Thank you.

It does not account for only populating one row from each category

0 Kudos
JimCousins
MVP Regular Contributor

There was not a mention of anything like this in your post, and this is a bit vague. Could you be more specific about your comment and just what it is you wish to do?

Jim

0 Kudos
Kapil_DevAdhikari
Emerging Contributor

@Jim Cousins, I have updated my question and simplified some conditions.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Since you posted this in ArcGIS for Desktop Training , a training space, is this an exercise you are trying to solve?  If so, do you have to use a specific set of tools or is everything on the table for use?  Are you comfortable with writing or using any Python code?

0 Kudos