Parent Topic: Vector Editing

Attribute Editing and Querying

The Attribute Query panel is launched from the "Attributes..." button on the Vector Editor. This panel is used for displaying the attributes of the vectors as well as performing queries on the attribute fields for the current layer.

The name and descriptor of the current layer appear at the top of the Attribute Query panel. Below this are two labels and a list of shapes with all of their attribute field values. The label on the left side shows how many shapes are selected or highlighted in the list out of the total number of shapes in the layer which is indicated on the right side.

The shapes showing in the list correspond to the current shapes.

To highlight shapes in the list, select them using the mouse. Multiple shapes can be selected by dragging through the list or by holding down the <CONTROL> key while selecting shapes in the list. These selected shapes will also be highlighted in the main imageworks window.

Below the list is a text field for entering a new query expression or selecting a previously entered expression. The query expression must follow the rules of the expression grammar.

Above the query text field are two radio buttons, these control the scope of the query. The default is set to "All", in which case the query is applied to all vectors in the current layer. If the other option, "Selected Shapes Only" is chosen, then the query is only applied to any currently highlighted vectors. This option is useful for refining searches.

Every time a new query expression is entered in the text field, the new expression is stored in a buffer. This buffer stores, at most, the last ten query expressions that were entered. To scroll through the contents of this buffer, press the up and down arrow buttons on the side of the text field. Note that this buffer stores query strings whether or not they follow the rules of the expression grammar. Also, if a previously entered expression is modified, the modified expression is stored as a separate expression in the buffer.

Pressing <RETURN> in the query expression's text field or pressing the "Query" button applies the query expression to the list of shapes. The shapes that satisfy the query expression become the new current shapes, replacing the contents of the list.

The "Attributes..." button at the bottom of the panel launches the Attribute Editor.

See Also: Attribute Editing, Selecting Shapes and Vertices

Attribute Field Definition
The Attribute Editor can be launched from the "Attributes..." button on the Vector Query Panel. This panel permits the viewing and editing of attribute field information for the current layer.

The characteristics of each field are displayed in column form, with the the name of the field displayed at the top. All the fields may be edited except for the "Type"; this is set at the time the field was created and cannot be changed.

Each of the field characteristics is summarized below.

Name: The name of the field. Although there is no limit on the length that the name may have, it is typically only 8-12 characters. This is how the field is referred to in a query. All valid ASCII printable characters are allowed.

Description: Typically longer than a name, it can be a brief sentence describing the field.

Type: This is a characteristic which cannot be modified, it is set at time of creation. Valid Types are "Integer", "Double", "Float", "Text", and "Integer List".

Width: This indicates, for numeric data, the width of the area that the number is to be printed in. If necessary it will be padded on the left or right to make up the field width. Numeric data which exceeds the width will not be truncated. For "Text" data the width indicates the maximum length of the the string. Although this is not enforced in the PIX format, other formats may truncate the string at the supplied limit when exported.

Precision: Valid only for floating point numbers, this indicates the number of characters you wish to display after the decimal point. This value only affects the display and does not round off the data in any way.

Justification: Data when displayed may be right or left justified. This is valid for all fields except for "Integer Lists".

Default: This entry shows the default value for the field. If there are existing shapes when the default value is changed, those shapes' values will not change, even if they had the same value as the old default. Only subsequently created shapes will be assigned the new default value.

The "Add New Field" button launches a panel for creating and adding a new field to the current layer.

Adding Fields
The "Add Field" panel is launched by pressing the "Add Field" button on the Attribute Editor. This panel allows the user to select the data type and to set the default value of the new attribute field to be added to the current layer.

Selecting the "Accept" button creates the new field and adds it to the current layer. The new field is named "Field" by default, but can be changed provided that it does not conflict with any existing names. It is important to select the correct "Data Type". Unlike the other values, this setting cannot be changed after the field has been created.

If there are existing shapes in the layer when this new attribute field is added, those shapes automatically inherit the new field with the default value. Any new shapes created in the layer will also have this new field with the default value.

Selecting the "Cancel" button cancels the operation and closes the "Add New Field" panel.

See Also: Attribute Editing and Querying

Editing Many Attributes Simultaneously
An attribute of more than one shape may be edited using the following sequence. First, either using the "Vector Editing Function" or the "Vector Query Panel", select and highlight all the shapes you wish to edit. After this selection has been made, use the Attribute field in the Vector Editor to make your changes. The changes will then be made to all the highlighted shapes.

Query Expression Grammar
Query expressions must follow the grammar structure of EXPR, which is defined below. There is no limit to the length of a query expression.

         EXPR:   PRIMARY
                 unary_op (EXPR)
                 (EXPR) binary_op (EXPR)

      PRIMARY:   field OP value

           op:   =
                 <
                 >
                 <=
                 >=
                 <>

     unary_op:   not

    binary_op:   and
                 or
In the above grammar definition, "field" represents a field name and "value" represents a field value. Query expressions are always case insensitive. This applies to attribute field names as well as string fields.

For example, the following query expressions are equivalent:

 CROPTYPE = WHEAT
 croptype = wheat
 CropType = Wheat
 Croptype = WHEAT
The field name does not have to be specified in full. That is, pattern matching is performed for the field names. However, this pattern matching only works when the first letter or letters of the field name are given. If a pattern is given but it does not uniquely identify one field name (it matches more than one field name), then the first field matching the pattern is used in the query.

For example, if the current layer has one field called "CropType", then query expressions (1) and (2) would be valid while (3) would not be because of the pattern-matching rules. Query expression (1) and (2) would produce the same results if applied to the same set of shapes.

 (1) CropType = wheat
 (2) Crop = wheat
 (3) Type = wheat
If a field name contains non-alphanumeric characters, then it must be enclosed in double quotes. For example:

 "Crop_Type" = wheat
 "Crop Area" > 3000
If a value contains non-alphanumeric characters, it must also be enclosed in double quotes. For example:

 LOCATION <> "ORANGE COUNTY"
Query Expression Examples
Assume the current layer has these attribute fields defined:

    Attribute Field Name     Data Type

    Latitude                 float
    Longitude                float
    County                   string
    Population               integer
To find, in the list of highlighted shapes in the Attribute Query panel, the shapes that have both a latitude greater than 45.3 and a longitude less than or equal to 62.7, this is the query expression to use:

    (Latitude > 45.3) and (Longitude <= 62.7)
Other examples of valid query expressions:

    ((Latitude = 37) and (Longitude >= 62.7)) or (Population <= 5000)
    (Latitude>25) or (County = "Tweed Township")
Here are some queries which would produce the same results for the same set of highlighted query shapes:

    Population <= 60000
    not (Population > 60000)
    (Population>0) and (Population<60001)

Parent Topic: Vector Editing
About PCI Help Gateway