Selection in Manifold is choosing some objects in a map, or some records in a table, usually by interactive means like pointing and Ctrl-clicking in a table or in a drawing. Labels can also be selected, as can tiles in images. This idea of selection is a different idea than the use of SELECT in SQL, even though the word selection is used to describe both. Selection as we mean it here is a simpler, more interactive thing, like clicking a file in Windows File Explorer to highlight it. For selection in SQL, see the SQL Basics topic.
A table, or a drawing's table, must have a key field with a btree index (and not a btreedup
or some other form of index) in it for selection to work. If the
table does not have a btree
index, selection will not be
available. To add an index to a table that does not have an index,
see the Add
an Index to a Table topic.
Manifold provides four distinctive means of working with selections:
Point and Click Selection using the mouse or keyboard shortcuts, to select objects or records of interest in visual display windows or in tables.
Menu Selection / Keyboard Selection using the Edit pull down menu, or using analogous Windows-style keyboard shortcuts, like Ctrl-A to Select All.
Dialog Selection using the Select pane, which provides an interactive, pane based interface for making selections using simplified templates or arbitrarily complex expressions, and which also allows us to save selections and to make Boolean combinations of saved and new selections. See the Select Pane Guide topic.
Selection using SQL Functions by writing SQL queries that use special functions that are analogous to the above three selection methods.
Selection tools can be used in combination to get exactly the right selection desired. For example, if we already have selected some records in a table using the mouse we can further modify the selection using the Select pane. We can also start with the Select pane and then modify the selection using interactive selection in tables or drawing windows.
A simple way to select objects in drawings or records in tables is to use commands like Select All that appear in menus or are keyboard shortcuts like Ctrl-A.
For simple selections, the Edit main menu choice provides four selection commands, which are matched to keyboard shortcuts as follows:
Select All |
Ctrl-A - Select everything in the active window (objects in drawings, labels in label components, frames in layouts, records in tables). Selects only within the active layer in maps. |
Select None |
Shift-Ctrl-A - Deselect everything in the active window (objects in drawings, labels in label components, frames in layouts, records in tables). Deselects only within the active layer in maps. |
Select None Map |
Deselects everything within all layers in a map. Equivalent to Select None for components other than maps. |
Select Inverse |
Ctrl-I - Inverts the selection, deselecting what was selected and selecting what was not selected. |
There are two ways to Select None from the keyboard: either do a Ctrl-A followed by a Ctrl-I or do a Shift-Ctrl-A. Which sequence is faster or more convenient depends on taste and dexterity.
The table below shows three selected records. Selected records are shown in red selection color. Select or deselect a record in a table by Ctrl-clicking it.
If desired, we can change the selection
color used by Manifold in the Tools
- Options dialog. This allows us to use a color
different than red
selection color in cases where a map already uses very much red color
or to provide a more discernible color in case of color blindness.
A selection in a table is simply a subset of records in that table that we have highlighted in red selection color to belong to that selection. It is a way of choosing records to be a part of a group, usually so we can do something with the records in that group. For example, in the table above we might want to increase the price of selected products by using the Transform pane to increase the Unit Price value of selected records by 10%. An analogy might be highlighting several files in Windows File Explorer so we can copy them all at once.
Press in the Selected
button in the main toolbar to show only selected records in the table.
Alternatively, use the View - Filter menu choice to filter
a table view to show only selected records.
Selections are often used as "scratch pad" temporary sets of items of interest and are often used interactively. For example, we might browse a table of products where would like to increase or decrease the dealer discount on some items. While scrolling through the table we select those we want to change and then we can use the Transform pane to alter the discount percent only on those records in the selection.
Important: Selection only works in tables that have a btree index on one of the fields in the table. Most Manifold dataports that import drawings will automatically create an mfd_id field in the drawing's table and will create a btree index on that mfd_id field. Tables that are imported from databases usually already have an index in them, since DBMS people almost always will have one or more indexes in their tables for performance reasons.
Some dataports that import from unsophisticated formats, such as .txt or .csv,, to ensure consistency with the original data, will not create an mfd_id field and will not create a btree index. Such tables can be viewed, and we can SELECT from them using SQL, but we cannot edit them and we cannot use selection within them as discussed in this topic until we add a btree index. Lucky for us, a btree index is easy, really easy, to add. See the Adding an Index to a Table topic.
Selection in Manifold has the following characteristics:
One table - A selection is a subset of records in a specific table.
Live records - A selection is not a separate copy of records: it is a way of marking some records in the table as part of a group of interest. We can work with a selected record, such as editing the contents of the record, just as we could with any record. The red selection color will not interfere.
No modification - Selecting a record does not modify the record in any way. Manifold infrastructure maintains the "bookmark," as it were, that indicates a record is part of a particular selection with no modifications to the record or to the table.
Temporary - A selection is a temporary grouping that disappears when the data source in which it was made is closed. For components stored in a .map project file that means a selection persists until that project is closed. For example, if we make a selection in a drawing that is stored in our project, we can close that drawing and when we re-open it the selection will still be there. However, if we close the .map file (which is the data source for all the components that are stored in that .map project file) and then re-open that .map file the selection will no longer be around. If we want to save a selection, we can do so using the Select pane.
Requires a btree index - Selections only work in tables that have a btree index on at least one of the fields in the table. If we do not know if a table has a btree index we can open the table in a window and then choose Edit - Schema to take a look at the schema. The Info pane will also report the primary index field for the table, if any.
In addition to this topic, it is a good idea to read the Select pane topic.
Drawings, either in their own window or as layers in a map window, are just a different visual interface for displaying a table with records that contain vector geometry data. When we select objects in a drawing, which we can do interactively with the mouse, we are simply selecting records in the associated table using a different visual interface. When we make a selection in a drawing window the selection will also be shown in red selection color and the corresponding records in the drawing's table also will be shown in red selection color.
Whether we Ctrl-click objects in the drawing with a mouse or Ctrl-click on rows in a table, in both cases we are simply selecting records in a table. A drawing window is just a specialized way to display vector data from a table. Selecting objects in a drawing also selects the corresponding records in a table. Selecting records in a table automatically selects the corresponding objects in the drawing.
Using a drawing of Mexico as an example, we select a record in the drawing's table.
Ctrl-click on a record in a table to select it.
The record is shown in red selection color and the corresponding object in the drawing window is also automatically selected and shown in red selection color.
If other drawings show that same table, they too will automatically show the selected object in red selection color, adjusted for opacity settings if the layer for that drawing is not at 100% opacity.
At left above we see a map that includes as a layer a drawing, Mexico 2, using the same Mexico Table. At right above we see a second map that has a third drawing, Mexico 3, that also is created using the same Mexico Table, but with different formatting. The Mexico 3 layer has 60% opacity applied in the Layers pane.
In every case, whenever a drawing is created from the same table, if a record in the table is selected, all objects in every drawing layer created from that record will also be selected.
Above at left we see the Mexico 2 drawing open in its own drawing window, zoomed in to the border between the selected area and the adjacent area. Above at right we see the Mexico 3 drawing open in a drawing window. In this example we have drawings created from the same table shown in five different windows. All of them have their selections synchronized to whatever is the selection in the table.
If we change the selection in the table, the selected objects in all of the drawings will also change. If we change the selection in any of the drawing layers that show the same layer, all of the other drawings will also have their selection changed to match, as will the table.
Using a drawing of Mexico as an example, we select an additional object in the drawing.
Ctrl-click on an object in a drawing to select it. We have Ctrl-clicked the province of Coahuila.
The object is shown in red selection color and the corresponding record in the table window is also automatically selected and shown in red selection color.
If we have any other windows open using drawings for that same table, those drawings and drawing layers will also be automatically updated.
Images, either in their own window or as layers in a map window, are just a different visual interface for displaying a table with records that contain raster tile data. When we select tiles in an image, which we can do interactively with the mouse, we are simply selecting records in the associated table using a different visual interface. When we make a selection in an image window the selection will also be shown in red selection color and the corresponding records in the drawing's table also will be shown in red selection color.
Whether we Ctrl-click tiles in the image with a mouse or Ctrl-click on rows in a table, in both cases we are simply selecting records in a table. An image window is just a specialized way to display tile data from a table. Selecting tiles in an image also selects the corresponding records in a table. Selecting records in a table automatically selects the corresponding tiles in the image.
Using a satellite photo image of the Pentagon as an example, we select a tile in the image. This is a very small image by Manifold standards, with just a few tiles to show how selection of tiles in images works.
In the table illustration above we have right-clicked the column header for the Tile field and chosen Style, to change the format for the Tile field from the default format that shows the size of the tile and the number of channels, to a format that reports the size of the tile as well as the data type of each channel and the number of channels.
Ctrl-click in an image to select the tile for that location.
The tile is shown in red selection color and the corresponding record in the table window is also automatically selected and shown in red selection color. Ctrl-click at a different location in the image to add that tile to the selection in the image.
The second tile is also shown in red selection color and the corresponding record in the table window is also automatically selected and shown in red selection color.
Important: Despite the identical "select" word that is used, selection in Manifold is a different notion than the use of SELECT statements within SQL queries.
SELECT and selection have differences:
Results table vs. Original table - A SELECT query in SQL produces a report, called a results table, of what the query generates. Simple queries might create a results table that looks very similar to the original table, but queries which do a lot of manipulation can produce results tables that do not look anything at all like the original table. Depending on what the query does, sometimes we might be able to use the results table as a viewport into those portions of the original table that the report shows, such as fields and records from the original table, and reach into and modify the data in those records. In contrast, selection is highlighting records in the original table that is open in a table window. Selection shows "live" records in the original table. They are highlighted in red color to indicate they belong to a group of interest but otherwise are just the same as all other records. We can edit them or modify them just like any other record in the table.
Multiple tables vs. One table - SELECT can generate results from one or more tables, choosing, creating or renaming fields on the fly and possibly creating entirely new records, for example based on aggregate functions. With selection we simply highlight existing records exactly as they are within one, original table.
Command Line vs. Interactive - SELECT is entirely a construct within SQL language, an activity like programming or issuing a series of text commands to a command prompt, while selection tends to be used interactively via point-and-click mouse actions within visual displays or within dialogs.
Abstract scale vs. Human scale - SELECT is the first choice for data sets so big no human can ever browse them interactively, while selection finds more use with smaller data sets that can be productively browsed interactively. We are not going to scroll through a table with a billion records to select a few here and there with a ctrl-click, but in a table with a few hundred records we might find that very convenient.
SELECT and selection have similarities:
Making a Choice - Both SELECT and selection are ways to choose subsets of data, to narrow down many records into those of interest.
Temporary - Both SELECT and selection are temporary. Unless saved in some way, if we close the results table the result of the SELECT goes away and if we close the window in which a selection was made the selection goes away as well. If desired, we can save the result of a SELECT using SELECT INTO and we can save selections using the Select pane.
First Steps - Both SELECT and selection are often the first steps in subsequent doings, SELECT often feeding other actions within SQL and selection leading to combinations between selections or transformation of selected data using the Transform pane or other means.
Programmatic - Both SELECT and selection can be used from within queries and scripts, taking advantage of what they offer within automation. That is unusual for selection, which tends to be more of a casual, interactive facility.
Although SELECT tends to be the first choice for larger data sets, Manifold selection infrastructure can easily work with the same very large data sets as can Manifold SQL with SELECT. That capability is normally used in queries and scripts but the capacity for very large numbers of records to participate in selections pops up during interactive use when drawings can show large numbers of objects, and thus involve many records.
Next: Select Pane Guide