Skip to main content
Corrects an incorrect function name. Rest is just to get to 6 characters of editing.
Source Link

What you are looking at is an Advanced Field Calculation.

It's a little confusing because you're kind of referencing it backwards. If you right-click on a field in an attribute table and select the field calculator, you'll notice an option in the field calculator window to change the parser to Python as well as a check box named 'Show Code Block'. When checked, the 'Show Code Block' check box allows you to perform an advanced field calculation by defining a custom function and using that function to calculate the values of the field.

Your Code Block would go into the Pre-Logic Script Code section as a custom function. Your Expression would go into the Field Calculation Expression section below that (In my case: Site_ID =)

enter image description here

So crossing() as defined in the Pre-Logic Script Code window is a function, which takes two parameters, crosses and row_score.

In the second window, the parameters (crosses and row_score) are being passed to the crossescrossing() function by means of the values in the fields "CROSS_ROW" and "ROW_SCORE", respectively, for each record in the attribute table.

So in this function, the crossing() function will be executed against each value in the 'Site_ID' field. If the value held in the field "CROSS_ROW" for that particular record is not equal to 0, a value of 5 will be returned and populated into the 'Site_ID' field for that record. Otherwise, if the value held in the field "CROSS_ROW" is not equal to 0 (!=), then the value held in the field "ROW_SCORE" will be returned and populated into the 'Site_ID' field for that particular record.

EDIT: To more properly answer your question: encapsulating something in exclamation marks means value from the field named whatever is encapsulated. So the value of the field named !CROSSES! for this record. The reason everything is in quotes is because whoever wrote this was probably doing this through ESRI's ArcPy Site Package which would require this expressions and code blocks be passed in as a string.

What you are looking at is an Advanced Field Calculation.

It's a little confusing because you're kind of referencing it backwards. If you right-click on a field in an attribute table and select the field calculator, you'll notice an option in the field calculator window to change the parser to Python as well as a check box named 'Show Code Block'. When checked, the 'Show Code Block' check box allows you to perform an advanced field calculation by defining a custom function and using that function to calculate the values of the field.

Your Code Block would go into the Pre-Logic Script Code section as a custom function. Your Expression would go into the Field Calculation Expression section below that (In my case: Site_ID =)

enter image description here

So crossing() as defined in the Pre-Logic Script Code window is a function, which takes two parameters, crosses and row_score.

In the second window, the parameters (crosses and row_score) are being passed to the crosses() function by means of the values in the fields "CROSS_ROW" and "ROW_SCORE", respectively, for each record in the attribute table.

So in this function, the crossing() function will be executed against each value in the 'Site_ID' field. If the value held in the field "CROSS_ROW" for that particular record is not equal to 0, a value of 5 will be returned and populated into the 'Site_ID' field for that record. Otherwise, if the value held in the field "CROSS_ROW" is not equal to 0 (!=), then the value held in the field "ROW_SCORE" will be returned and populated into the 'Site_ID' field for that particular record.

EDIT: To more properly answer your question: encapsulating something in exclamation marks means value from the field named whatever is encapsulated. So the value of the field named !CROSSES! for this record. The reason everything is in quotes is because whoever wrote this was probably doing this through ESRI's ArcPy Site Package which would require this expressions and code blocks be passed in as string.

What you are looking at is an Advanced Field Calculation.

It's a little confusing because you're kind of referencing it backwards. If you right-click on a field in an attribute table and select the field calculator, you'll notice an option in the field calculator window to change the parser to Python as well as a check box named 'Show Code Block'. When checked, the 'Show Code Block' check box allows you to perform an advanced field calculation by defining a custom function and using that function to calculate the values of the field.

Your Code Block would go into the Pre-Logic Script Code section as a custom function. Your Expression would go into the Field Calculation Expression section below that (In my case: Site_ID =)

enter image description here

So crossing() as defined in the Pre-Logic Script Code window is a function, which takes two parameters, crosses and row_score.

In the second window, the parameters (crosses and row_score) are being passed to the crossing() function by means of the values in the fields "CROSS_ROW" and "ROW_SCORE", respectively, for each record in the attribute table.

So in this function, the crossing() function will be executed against each value in the 'Site_ID' field. If the value held in the field "CROSS_ROW" for that particular record is not equal to 0, a value of 5 will be returned and populated into the 'Site_ID' field for that record. Otherwise, if the value held in the field "CROSS_ROW" is not equal to 0 (!=), then the value held in the field "ROW_SCORE" will be returned and populated into the 'Site_ID' field for that particular record.

EDIT: To more properly answer your question: encapsulating something in exclamation marks means value from the field named whatever is encapsulated. So the value of the field named !CROSSES! for this record. The reason everything is in quotes is because whoever wrote this was probably doing this through ESRI's ArcPy Site Package which would require this expressions and code blocks be passed in as a string.

Post Migrated Here from stackoverflow.com (revisions)
Source Link
MrBubbles
  • 833
  • 5
  • 15

What you are looking at is an Advanced Field Calculation.

It's a little confusing because you're kind of referencing it backwards. If you right-click on a field in an attribute table and select the field calculator, you'll notice an option in the field calculator window to change the parser to Python as well as a check box named 'Show Code Block'. When checked, the 'Show Code Block' check box allows you to perform an advanced field calculation by defining a custom function and using that function to calculate the values of the field.

Your Code Block would go into the Pre-Logic Script Code section as a custom function. Your Expression would go into the Field Calculation Expression section below that (In my case: Site_ID =)

enter image description here

So crossing() as defined in the Pre-Logic Script Code window is a function, which takes two parameters, crosses and row_score.

In the second window, the parameters (crosses and row_score) are being passed to the crosses() function by means of the values in the fields "CROSS_ROW" and "ROW_SCORE", respectively, for each record in the attribute table.

So in this function, the crossing() function will be executed against each value in the 'Site_ID' field. If the value held in the field "CROSS_ROW" for that particular record is not equal to 0, a value of 5 will be returned and populated into the 'Site_ID' field for that record. Otherwise, if the value held in the field "CROSS_ROW" is not equal to 0 (!=), then the value held in the field "ROW_SCORE" will be returned and populated into the 'Site_ID' field for that particular record.

EDIT: To more properly answer your question: encapsulating something in exclamation marks means value from the field named whatever is encapsulated. So the value of the field named !CROSSES! for this record. The reason everything is in quotes is because whoever wrote this was probably doing this through ESRI's ArcPy Site Package which would require this expressions and code blocks be passed in as string.