The Choice tab in the Style dialog for fields in tables allows us to specify a set of choices for integer numeric, numeric vectors, or text fields. Choice styling is used for two purposes:
For example, using Choice styling, land use classification numeric codes can be aliased to a corresponding text description, showing the text description Cropland and Pasture instead of the numeric code 21.
When entering new records or editing Boolean fields in existing records, Boolean fields always show a pop-up menu choice of true or false, with no need to explicitly specify choices, since there are always only two possible choices for Boolean fields.
See the video versions of this topic: First Look - Choice Styling - Pop-up Lists and First Look - Choice Styling - Aliases.
The illustration above shows the Choice tab as used to provide a list of allowed choices for a text or an integer numeric field. Note that the Value and Show as values are the same. When providing a list of allowed choices, the Show as value can be any text string, including a text string that shows numbers.
The illustration above shows the Choice tab as used to provide aliases for integer or text fields. Note that the Value entries are integer numbers and the Show as values are text.
Standard |
A list of prebuilt styles. The list of styles available will depend on the data type of the field being styled. See the Styling Table Fields topic for information on the Standard tab. |
Choice |
The Choice tab allows entry of list of choice values that are integers, and how those choice values should be displayed. Editing fields that have a choice style will pop open a drop down list of allowed choices. |
Delete the selected row or rows. Enables when a row is selected by Ctrl-clicking the row. See the Selection topic for selection moves that work with rows in tables and in table-like row and column presentations in dialogs. |
|
Value |
The numeric or text value to be displayed using the corresponding Show as entry. The table will be sorted using |
Show as |
A preview of what the style will display, using example values of the field's data type. The preview will automatically be updated given any options specified in the Digits box, the Positive degrees box, or picked for a language. |
(* row) |
Double-click into the Value cell for the last row, marked with an asterisk * in the row handle, to add a new row to the Choice list.
Entering a new Value will automatically enter the same value for the Show as cell, and will insert that new row by sorting the Value column to put numbers first, scrolling the Choice list as necessary to bring the new, sorted position of the new row into view. |
Language |
Appears when the Style dialog is launched for a numeric field. Choose a language-country pair, specifying a language as used in a particular country. Used with the Standard tab, not with the Choice tab. |
Appears when the Style dialog is launched for a numeric field. Language-country picker button. Launch the Language dialog. Used with the Standard tab, not with the Choice tab. |
|
OK |
Apply the specified style and exit the dialog. |
Cancel |
Exit the dialog without making any changes. |
Double-click into either a Value or Show as cell in the Choice list to edit it. Changing a Value will resort the Choice list to show that new Value in sorted order. Editing a Choice list will instantly update any open table windows or Info panes that show the subject table and field to display their contents using the edited Choice list.
Add a row to a choice list by double-clicking the Value cell in the last row, which is marked with an asterisk * in the row handle. Entering a new Value will automatically enter the same value for the Show as cell, and will insert that new row by sorting the Value column to put numbers first, scrolling the Choice list as necessary to bring the new, sorted position of the new row into view. We can then change the Show as cell to be whatever we desire if we do not want it to be the same as the Value.
Delete a row by Ctrl-clicking the row to select it, and then pressing the Delete button in the Style dialog's toolbar.
To add a row to the Choice list, double-click the Value cell in the last row, which is marked with an asterisk * in the row handle:
Double-click into the Value cell and enter the desired value.
Press Enter to commit the edit to the Value cell and the same value will be immediately copied into the Show as cell. That facilitates fast addition of choices to provide a pop-up list of allowed choices when editing a field.
The newly added row will appear in the list in sort order using the Value field. The list will automatically be scrolled so the new row appears in view.
If some other value is desired in the Show as field, for example, when using Choices as aliases, click into the Show as cell and enter the desired value, pressing Enter to accept the edit.
Delete a row by selecting it and then pressing the Delete toolbar button.
Ctrl-click a row to select it. The selected row will be shown in red selection color. To delete more than one row at a time, select more than one row, using standard selection moves as used in tables. Selected rows do not have to be adjacent.
Press the Delete button in the toolbar.
Selected rows will be deleted.
We can edit any cell, either a Value or a Show as cell, to edit it.
Double-click a cell to edit it. Make the changes desired and then press Enter to commit the edit.
If we edit a Value cell to change the value, the row will be resorted to appear in the Choice list in order sorted by Value, with numbers coming first. If we edit either a Value cell or a Show as cell, what is displayed for that field in any open table windows or the Info pane will be immediately updated.
Providing a pop-up list of allowed choices when editing a field is one of the main uses of choice styling.
In this example, we want to create a drawing that shows the locations and types of power plants in Pennsylvania. To standardize editing, we want to provide a choice list of the primary energy source used for each power plant, to enable choice from a list for the source when adding a new power plant point to the drawing.
We create a new drawing called power plants. In the associated power plants Table, we use the Schema dialog to add an nvarchar text field called Source.
In the open table, we right-click on the column head for the Source field and we choose Style.
In the Style dialog we click the Choice tab.
In the Choice tab we double-click the Value cell to open it for editing, to add a new row with values and Show as text.
Enter the text biomass and press Enter.
That adds a new line to the Choice tab list. The Show as value by default will simply repeat what we entered into the Value cell.
We press the down arrow key to move the table cursor down one row, and then we press Enter to open that next cell for editing.
We enter the text coal and then press Enter.
That adds another line with the text coal for both the Value and the Show as cells.
We continue as above to add a total of nine rows, covering the various sources of power that we will use in our table, from biomass to wind.
If we make any mistakes, we can double-click into the cell with the error and correct it. If we want to delete a row, we can Ctrl-click the row to select it, and then press the Delete key on the keyboard.
When we are happy with the choice list we have created, we press OK.
The table now has choice styling for the Source field. Although we have not yet entered any records, the table and drawing are ready to go.
We create a map using the power plants drawing as a layer, and using OpenStreetMap as a base layer. We also add a Google satellite layer, above the OSM layer. Our plan is to use OSM to navigate to places where we know power plants are located, and then we will turn on the satellite layer to zoom in to a satellite view of the power plant, allowing us to click a point precisely where we want to mark the location of the power plant.
Our first plant will be the Beaver Valley Nuclear Generating Station. We zoom into the plant's location and with the focus on the power plants layer we choose Create Point as the cursor mode.
Clicking at the spot where we want to place a point will mark the spot with a provisional point and will automatically open the Info pane, to allow us to enter any attribute field values we wish.
In the Info pane, we double-click into the Source cell, and we choose nuclear from the resulting list.
Note that the choice list we specified for that field in the table window is active in the Info pane when editing that field, just as it is in the table window.
Press Add Record to add the provisional record as a point to the drawing.
A new point appears in the drawing. In the illustration above, we have styled the drawing to show points as large green dots.
A new record for the point also appears in the drawing's table.
If we would like to edit the Source cell, we can double-click it to edit it.
That pops open the choice list. If we had made a mistake in choosing the power source, we could correct the mistake by choosing a different option from the list. Not clicking any choice abandons any change and leaves the value as originally entered.
Next, we pan and zoom the map to the next power plant we will add. We pan and zoom to the town of Beaver, Pennsylvania, on the outskirts of which is located a solar power plant.
With the cursor still in Create Point mode, we click on the solar plant.
In the Info pane, we double-click on the Source cell and we choose solar. Press Add Record to add the point.
A new point appears in the drawing.
A new record appears in the table as well. We can continue in this way to add as many power plants as we like.
A similar process works in any situation where we want to add values to a table by choosing from a list of allowed choices. We first create the list of allowed choices in the Choice tab of the Style dialog for that field, using the same value in the Value cell and the Show as cells for each row, and then those choices will appear whenever we edit the field in the Info dialog or in a table window.
Providing aliases for text or integer values that can show the contents of a field in more understandable form is one of the main uses of choice styling.
In this example, we use the Choice tab to provide descriptive, text aliases to display instead of difficult to understand integer numeric codes. We work with a land use / land cover data set showing land use in the San Francisco Bay area.
We work with a map that shows a land use drawing layer along with a base layer of Bing streets. The different areas in the land use drawing have been colored by their land use code.
Opening the drawing's table, we see that a Code field gives the USGS land use code for each area.
We can zoom into the map for a closer look, and we can add a labels layer that shows the Code number for each area. As can be seen from the illustration above, the code numbers are not at all user friendly, even if we have a good memory for what USGS code numbers mean.
We would like to change the style for the Code field so that instead of showing integer codes, it instead displays descriptive text for each code number.
We right-click on the column head for the Code field and choose Style.
Click the Choice tab.
In the Choice tab display, double-click the row's Value cell to open it for editing.
Enter 11 and press Enter. That enters 11 both in the Value cell and in the Show as cell. We would like the number 11 to be displayed as more descriptive text, so we double-click into the Show as cell and we enter Residential. Press Enter to apply the edit to the cell.
We proceed to add more rows to the list, in each case entering an integer number in the Value and the corresponding text to show in the Show as cell for the row.
This seems like it would take a long time for a long list, but the work goes quickly. Manifold will soon add the capability to populate a Choice list by reading a table instead of having to manually enter the Value and Show as text for each row.
If we make any mistakes, we can double-click into the cell with the error and correct it. If we want to delete a row, we can Ctrl-click the row to select it, and then press the Delete key on the keyboard.
When we are happy with the choice list we have created, we press OK.
When we press OK, the Choice list will be used to display the Show as text description for each corresponding integer number given in the choice list's Value column.
Note that the Code field is still an integer field and that the Code attribute for each area is still an integer number. The only thing that has changed is how that integer number is displayed in the table. Instead of being displayed as a number, it is displayed as the corresponding descriptive text that we entered into the Show as cell.
The map also updates, so that the values displayed for the Code field in the labels layer now use the descriptive text we specified in the Show as cells when styling the Code field. The map has become immediately more informative.
The usefulness of choice styling also shows up if we want to edit the Code values for different areas, because now we can pick from a list that shows descriptive text instead of having to enter integer numbers from memory.
For example, suppose we want to change the Code value for the area that is selected above, and is shown in red selection color.
We can scroll down to the corresponding record in the drawing's table, also shown in red selection color, and then double-click the Code cell for that record.
From the list of aliases we entered in the Choice dialog, we can choose Commercial Services.
That instantly changes the Code value for that record to the number corresponding to Commercial Services. That number happens to be 12, but we do not have to remember that, since choosing the descriptive text is a less error-prone way of choosing that number.
The land use drawing and labels are immediately updated with the new value.
If we deselect the area, we see that the thematic format, which uses the code number for Commercial Services, has also been updated. Remember, the values in the Code field are still integers. The Choice styling we specified only changes how those code numbers are displayed. Since the values in the Code field are still numbers, everything that depends upon those numbers, such as a thematic format that applies area fill color based on the number in the Code field, continues to work.
Another way to change the value in the Code field for an area is to pick the area with an Alt-click and to then change the value in the Info pane.
We Alt-click the same area to pick it. It appears in picked format in the drawing, outlined with small blue squares at each coordinate that defines the area.
Picking an object automatically also pops open the Info pane and brings it to the foreground of other panes.
We can double-click the Code cell in the Info pane to edit the value.
That pops open the choice list. We can choose some other item in the list, like Deciduous Forest Land. Choosing that item will assign the Code number that corresponds to that description in the Choice styling we specified.
Press Update Record to apply the edit.
Clearing the picked status of the area we see that the label has been updated, as has the thematic format used to color the area.
In the drawing's table, we see that the Code field for that record has also been updated.
We change it back to Residential, since that particular place in the Bay area is a residential area, not forest.
Remember, in all the above the Code field is still an integer number data type. All we have changed is how the numbers in the field are displayed. Instead of being displayed as integer numbers like 11 or 12, they are instead automatically aliased to be displayed as the descriptive text we entered.
How is the use of choice styling different from the use of JOINs to add a corresponding descriptive field to a table? Two big differences are that first, choice styling works during editing, so we can use a more understandable Show as text when editing instead of having to edit using numbers that may be difficult to remember, and second, choice styling is dynamic, automatically updating what is displayed.
We can see those differences by using JOIN to add a descriptive field to the table.
The USGS land use codes used in the land use drawing are shown in the table above. We can JOIN the Description field from that table into our land use Table to add a description field.
In the illustration above, we have copied the numbers from the Code field into a new Numeric Code column, and then we have hidden the Code field using the Layers pane. We do that so we can edit the Numeric Code field at will without messing up our neat and accurate land use drawing. We have also used the Join dialog to add a Description field to the table that has been joined from the USGS land use codes table.
At first glance, it looks like we have the best of both worlds. We have both the numeric land use code and also a text description. But we see the flaw in that arrangement when we edit the Numeric Code field for a record by double-clicking the cell.
Suppose we want to change 11, meaning residential land use, to 12, meaning commercial services.
That means, of course, that we must remember 12 is the code for commercial services. That is an error-prone challenge if we have many codes for many different land uses.
If we change 11 to 12, we see that the Description field has not changed. The reason it hasn't changed is that the Description values were joined in from a different table in a one-time process. We could update them based on any changes to the Numeric Code field, but that would require another use of the Join dialog. If we were up for some intermediate level SQL, we could, of course, write a quick query or an suitable expression that would power automatic updating of the Description field. But all that requires more thought than simply using choice styling.
Another way to get the best of both worlds, to see both the LULC code number as well as a user friendly text description, is to create a computed field based on a simple expression, that is simply the [Code] field:
If we change the Code value by picking a new choice from the descriptive list, the LULC Code field above will automatically change to show the new integer code.
The LULC Code field in the table above is a computed field using the above expression. It simply copies whatever number is in the Code field.
For example, if we edit the Code value in the second row to change it from Residential to Evergreen Forest Land, the LULC Code field will change from 11 to 42.
The values in the Code field are still integer numbers: they are only displayed as corresponding text values by the Choice styling applied. The LULC Code field shows a copy of whatever number is in the Code field for that row. It is a simple way of showing the code number without it being aliased in a descriptive way in the Code field itself.
A numeric vector data type provides two to four integer values in each field.
The table above has one field for each record, called uint vector, the name of the field serving as a mnemonic that the data type of the field is a numeric vector where the components of the vector are unsigned integers, in this case uint8x3 data type.
Suppose in this table we want each component of the numeric vector to be a value that is 0, 1, 128, or 255. We can use a choice setting to provide a pop-up list of allowed choices.
We right-click onto the uint vector column head and choose Style.
In the Choice tab we assign the above Value and Show as settings, and then we press OK.
That does not change the display, but it does set up a pop-up list of allowed choices.
When we click into the * row to add a new record, we get a menu to allow choosing the values for Value 1, Value 2, and Value 3, with a pop-up menu of allowed choices for each value.
For example, we can set the first value, that is, the first component of the vector, to 128.
That shows the proposed vector value in blue provisional color. We click again into the cell to set Value 2 to 255.
We click once more into the cell to set Value 3 to 1.
We now have a provisional value of [128, 255, 1].
Press Ctrl-Enter to commit the edit, or press Add Record in the Info pane, or right-click onto the record handle and choose Save Changes.
The new record appears in the table.
Note that the Show as value to be displayed can be whatever text we want, and we can change the Choice list as we like.
For example, we can right-click onto the uint vector column head and choose Style to edit the Choice list.
In the Choice list Show as column we double-click into the cells to edit them, so instead of showing numbers they show the words Nothing, Black, Gray, and White.
Press OK.
The table immediately updates to display the new Show as strings.
When we click into the * row to add another record, the new Show as strings will appear as choices in the pop-up list. For example, we can choose Gray for Value 2.
The default choice for a numeric vector for components we have not yet chosen will be zero so after we specify the value for Value 2, the provisional value for that field in the new row will be displayed as [Nothing, Gray, Nothing], corresponding to the numeric values of [0, 128, 0].
Filters will not show pop-up choice list menus.
For example, if in the numeric vector example shown above we right-click onto the last row's uint vector cell and choose Add - Filter, the pre-built filters displayed in the menu will use the default style, showing the integer numbers in the field, and not the display style taken from the Choice list.
Values in Tables not in a Choice List - When creating a choice list we normally provide a list that covers all of the different values that might appear in the table. If we apply a choice style to a table field and there is a value in the table that is not on our choice list, the value will appear as is, but shown in an unknown value color, the same as used with NULLs. If desired, we can change the unknown value color used by Manifold in the Tools - Options dialog.
For example, suppose using SQL, the Transform pane, or a simple Copy and Paste we changed the value for the Code field for the second record in the table above from 11, which is a code that our choice list has specified should be shown as Residential to the number 89, which is not a value that is matched by anything in the Show As list. The number 89 will be shown using unknown value color as seen in the illustration above.
If we were to right-click onto the Code column header, choose Style and then add another entry in the choice list for 89, then that new entry would be used.