SETITEM

 

evaluates an expression and assigns its value to a target item for the specified feature class of the specified coverage, or in the specified INFO data file.  UNLIKE the CALCULATE and MOVEITEM/MOVE commands in ARCPLOT and TABLES, SETITEM is not data type sensitive.  The target item can be character or numeric, and the expression can contain character and/or numeric data.

____________________________________________________________________________

 

SETITEM <cover> <feature_class>

<target_item> = {expression}

SETITEM <info_file> INFO

<target_item> = {expression}

 

ARGUMENTS

 

<cover> <feature_class> - indicates that the <target_item> exists within the <feature_class> of the input <cover>.

 

<cover> - the input coverage whose <feature_class> contains the <target_item>.

 

<feature_class> - the feature class (feature attribute table) which contains the <target_item>.

 

It can be indicated using one of the following keywords:

 

POINT

ARC

POLYGON

NODE

TIC

 

<info_file> INFO - indicates that the <target_item> exists within an INFO data file.

 

<info_file> - the INFO data file which contains the <target_item>.

 

INFO - required keyword to indicate that the first argument is an INFO data file.

 

<target_item> - the item to which the value of the {expression} is to be assigned.

 

It can be any type of item, character or numeric.

 

= - equals sign to separate the two sides of the SETITEM equation.

 

It is optional.

 

{expression} - the expression, which once evaluated, will be assigned to the <target_item>.

 

It can be a string or arithmetic expression.  Its value will be assigned to the <target_item> using the &SETVAR directive.

 

Any item from the input INFO data file can be used in the expression.  However, unlike with CALCULATE, the item name must be surrounded by angle brackets (<>), e.g. <AREA>.

 

Additionally, internal variables $RECNO and $SELNO can be used.  They too need to be surrounded by angle brackets.  $RECNO, as in ARCPLOT CALCULATE, evaluates to record number.  $SELNO, on the other hand, evaluates to the number of the record within the selected set, not within the entire INFO data file.  When no subset of the file has been selected, then $SELNO functions the same as $RECNO.

 

AML functions can be included in the expression, but if they aren't to be evaluated before being passed to SETITEM, they need to be included within single quotes (''), e.g. '[SQRT <AREA>]'.

 

If the <target_item> is numeric and the expression evaluates to a string, the <target_item> will be assigned 0, or NULL, and no warning will be given.

 

See EXAMPLES section for example expressions.

 

 

NOTES

 

- SETITEM runs from the ARC, ARCPLOT, and GRID modules of ARC/INFO, ver.  7.0.4.

 

- When run from ARCPLOT, SETITEM only processes records that are selected, unless no records are selected and then all records are processed.

 

- SETITEM is much slower than the ARC/INFO assignment commands, since SETITEM uses a CURSOR.

 

- SETITEM does not support RELATEs.

 

- SETITEM can be run from the command line or from a menu.  When the global variable: .R6MODE is set to MENU, then running SETITEM will popup a menu, unless all the required arguments are provided.

 

 

DISCUSSION

 

THE PROS - The purpose of SETITEM is to allow greater flexibility in the assignment of values to items in an INFO data file than do the CALCULATE and MOVEITEM/MOVE commands in ARCPLOT and TABLES.

 

SUPPORTS ALL DATA TYPES - The <target_item> can be any data type, and the {expression} can contain items of any data type.  In this way, the values from numeric items can be assigned to character items.  And the values from character items (providing they are numbers) can be assigned to numeric items.

 

SUPPORTS ITEMS WITHIN FUNCTIONS IN EXPRESSION - As with CALCULATE and MOVEITEM/MOVE the {expression} can contain AML functions, but unlike with these commands, SETITEM can contain items within the functions.  In this way, more types of calculations are possibile.  For instance, the trigonometric calculations can be performed on items (see EXAMPLE 3).

 

THE CONS - The down side of the greater flexibility of SETITEM, is that it is much slower (since a CURSOR is employed) and does not support RELATEs.

 

 

EXAMPLES

 

1) Say you have a coverage named STANDS and, within it's polygon attribute table, a character item named DATA which contains a numerical identifier.  You want to transfer the ID to a numeric item named STAND_ID.  You can do this by entering:

 

Arc: &RUN SETITEM STANDS POLYGON STAND_ID = <DATA>

 

Note that angle brackets need to surround any items, e.g. <DATA>, in the {expression}.

 

And now a look at the results:

 

Arc: LIST STANDS.PAT DATA STAND_ID

Record  DATA                           STAND_ID

1                                     0

2  800                              800

3  887                              887

4  water                              0

 

Note that if the <target_item> is numeric and the {expression} does not evaluate to a number, e.g. 'water', than zero is assigned to the <target_item>.

 

2) Say you want to create an alphanumeric stand ID by concatenating the character item named WATERSHED with a sequence number to populate STAND_ID, in this example a character item.  You can do this by entering:

 

Arc: &RUN SETITEM STANDS POLYGON STAND_ID = ~

Arc: <WATERSHED>'[SUBSTR 0000<$RECNO> [LEN <$RECNO>] 5]'

 

Note that single quotes need to surround AML functions, e.g.  '[SUBSTR...]', though functions within functions, e.g. [LEN...], should not be quoted.  Note also the use of the internal variable named $RECNO.  As with items, internal variables also need to be surrounded by angle brackets.

 

The [SUBSTR], substring function, is used to pad the $RECNO to 5 digits using 0's.

 

And now a look at the results:

 

Arc: LIST STANDS.PAT WATERSHED STAND_ID

Record  WATERSHED STAND_ID

1            00001

2  08L12     08L1200002

3  08L12     08L1200003

4  08L12     08L1200004

 

Woops, the first polygon doesn't have a WATERSHED ID, and probably shouldn't receive a STAND_ID.  To prevent this you can run SETITEM from ARCPLOT after doing a RESELECT.  For example:

 

Arcplot: RESELECT STANDS POLYGON WATERSHED <> ''

Arcplot: &RUN SETITEM STANDS POLYGON STAND_ID = ~

Arcplot: <WATERSHED>'[SUBSTR 0000<$SELNO> [LEN <$SELNO>] 5]' Arcplot: CLEARSELECT

 

And now a look at the results:

 

Arcplot: LIST STANDS POLYGON WATERSHED STAND_ID

Record  WATERSHED STAND_ID

1

2  08L12     08L1200001

3  08L12     08L1200002

4  08L12     08L1200003

 

See how STAND_ID is left blank when WATERSHED is blank, as these records were not part of the selected set.  Note that by using $SELNO instead of $RECNO, the sequence number only increments with selected records.

 

3) Say you want to concatenate multiple items: TOWNSHIP and RANGE, and prefix them with a 'T'.  You can do this by entering:

 

Arc: &RUN SETITEM PLSS.PAT INFO TOWN_CODE = ~

Arc: T<TOWNSHIP><RANGE>

 

And now a look at the results:

 

Arc: LIST PLSS.PAT TOWN RANGE TOWN_CODE

Record  TOWN   RANGE  TOWN_CODE

1  4S     16E    T4S16E

2  32N    7E     T32N7E

3  36S    4E     T36S7E

4  17N    40E    T12N40E

 

Note that trailing blanks are removed when the items are concatenated.  In this way, the fields in the <target_item> will not be lined up unless the lengths of the values in the input items are the same.  To make sure they line up you can use the [FORMAT] function:

 

Arc: &RUN SETITEM PLSS.PAT INFO TOWN_CODE = ~

Arc: T'[FORMAT ''%1,-4%%2,-4%'' <TOWN> <RANGE>]'

 

And the results will be instead:

 

Arc: LIST PLSS.PAT TOWN RANGE TOWN_CODE

Record  TOWN   RANGE  TOWN_CODE

1  4S     16E    T  4S 16E

2  32N    7E     T 32N  7E

3  36S    4E     T 36S  4E

4  17N    40E    T 12N 40E

 

4) Say you have an item named SLOPE which contains slope measured in degrees and you want to recalculate the values in percent-rise.  You can do this by entering:

 

Arc: &RUN SETITEM STANDS.PAT INFO SLOPE = ~

Arc: '[TAN [ANGRAD <SLOPE>]]' * 100

 

Note that the <target_item> may also be used in the {expression}.

 

And now a look at the results:

 

Arc: LIST STANDS.PAT INFO SLOPE

Record         SLOPE            SLOPE (previously)

1         0.000            0.000

2         5.241            3.000

3        19.438           11.000

4        21.256           12.000