Search Vector Data

The Search Vector Data tool searches for features in all loaded vector data by attribute value, name, or built in attributes of the layer like Feature Type or Index. When selected, the Search Vector Data (below) dialog is displayed.

The search vector data tool can be accessed from the Search Menu Search by Attribute, Name and Description. It can also be accessed from the Search Vector Data button on the Tools Toolbar, or the Search button on the Attribute Editor.

  The Search Vector Data button also displays an Attribute Editor Search Results list of all of the vector features (areas, lines, points and/or lidar) which match the specified Search Criteria. The Search Criteria can be applied to any attribute value of the loaded features, the display label field, or the description/ type field. The expression entered into the Query section updates the displayed rows in the corresponding Attribute Editor window when the Search button at the bottom is pressed.

The default search query will display all features in all layers. To change the default see General Configuration

To build a search query, type the query into the search box, or use the Query Builder attributes, operators, functions and values to build the query expression. Like other scripting syntax in Global Mapper, the attribute names, operators and functions are not case sensitive.

For a simple attribute query:

  1. Press the Clear Query button in the bottom right of the dialog to clear out the default query.
  2. Select an attribute from the Query Builder Attributes list, and double-click it or use the + button below the attribute list to add it to the query. Note the % characters surrounding the attribute name indicate it is a variable.
  3. Select the operator ( = , >, <, etc.) 
  4. With the attribute still highlighted in the attribute list, press the Load Values button above the Values section to populate the values list with the values of the selected attribute.
  5. From the Values list, double-click or select the desired value and press the + button to add the value to the query expression. Note the value will be added to the query inside quotes (' or ") if it is a text string.
  6. Optionally press the Validate button to test the expression.
  7. Press the Search button at the bottom of the dialog to perform the query. The features that match the query will display in the Attribute Editor window.

The Feature Types, Layer(s) and Feature Options sections at the top of the dialog can be used to further limit the search results.

Feature Types

In the Feature Types section of the dialog, feature types may be selected or disabled to include or exclude Areas, Lines, Points or Lidar data from searches. By default all feature types will be selected, so the result may include areas, lines, points or lidar.

Layer(s)

In the Layer(s) section, the search can be limited to specific layers, or the extent of data visible on the screen*.

All Enabled layers are visible layers that also have the option 'Allow Feature Selection/ Search from selected Layer(s)' checked in the Control Center right-click context menu. Layers that have been disabled from search and selection will appear with a red layer name in the Control Center.

Specific Layers can be used to constrain the search to particular layers. This is enabled by default when accessing the Search Vector Data from a Layer attribute list.

* There is a limitation on the number of features that can be listed. For Global Mapper 32-bit the feature limit is 1 million, for Global Mapper 64-bit the feature limit is 5 million.  To search Lidar data with more than the maximum number of features, you will have to use the 'Search Onscreen Features Only' option, and zoom in the viewer to reduce the number of features.

Feature Options

On-screen Features - Select this option to limit the results to only those features displayed on the primary 2D map.

Selected Features- Check this option to limit the search to within the current selected features. This option can be used to combine attribute search with other selection methods. To combine attribute searches with spatial queries, perform a selection using the Digitizer Advanced Selection Options (or other digitizer tool selection) and enable the Sync button. Then perform this attribute search with the Selected Features option enabled.

Query Builder

The query builder can be used to build an expression in the query box that search based on attributes of the loaded vector features. The desired attributes, functions and values must be double-clicked or added with the + button, so that the text in the query box shows a valid expression. It is also possible to type or paste directly into the query box.

Attributes

Attribute names must be contained inside of % characters in the query. Built-in named attributes, such as Feature Name and Index in Layer are contained inside of <> characters, and do not use the % to designate them. Highlight the attribute in the Attributes section of the query builder and select the + button to add the attribute to the query at the current cursor location.

Operators

The comparison operations are the following:

Operator Meaning Example 1 Example 2
= equals %Attribute1%='Value' %Attribute1% = %Attribute2%
>= greater than or equal to %Attribute1% >= 100 %Attribute1% >= 'C'
<= less than or equal to %Attribute1%<= 100 %Attribute1% <= 'Ba'
<> not equal to (see also Built-in named attributes) %Attribute1%<>"" %CONTINENT% <> 'North America'
> greater than %Population% >1000 <Feature Name> > 0
< less than %AREA% < 100 %Population%/%AREA% < 1000
() parenthesis (operations inside are executed first in the order of operations; they may also contain the inputs to a function) %Attribute1% = (%Attribute2%*10) %Density% <> (%Population%/%Area%)
and logical AND (returns features where both expressions are matched) %GROUP_AREA% < 1000 and %CONTINENT%= 'Europe' %GDP_MD_EST% > 500 and %POP_EST% < 1000000
or logical OR (returns features where either expression is matched)  %CONTINENT%= 'Europe' or %CONTINENT%= 'Asia'  
not logical Negation operator (this returns the inverse of the expression) not(<Feature Name> like 'U*') %CONTINENT% = 'Africa' and not ( %SUBREGION% = 'Western Africa' )
like matches a pattern (this can use the wildcard characters * and ?) %SUBREGION% like 'South*' %ELEVATION% like '??5'

These operators may be added to the query with the operator buttons, or they can be typed directly into the query box.

Additional expression operators may be typed in as well, such as mathematical operators (like +,-, *, /, ^). For a more complete list of operators, see Formula Calculator.

Simple Attribute Queries

The typical syntax for a single attribute query is:

%Attribute1% = 'Value'

%Attribute1% > 0

%Attribute1% <> ''

The attribute name in this case would be Attribute1, and the first query would find all features where Attribute1 equals (has the exact text of) Value. This value is a text string, so it should be contained inside of single or double quotes. The third query would find all feature that do not contain an empty or null attribute1.

For a numeric value, the quotes around the value are not necessary. The second query would find all features where Attribute1 is greater than 0.

An empty or null value may be represented by two single or double quotes ('' or ""). A not operator combined with an attribute name would also return features with null values. For example:

%Attribute1% = ''

not %Attribute1%

Either of these queries would find all features where attribute1 is empty or null.

The %% wrapper designates a variable attribute value, which will be tested for each individual feature based on its attribute value. The <> indicates special built-in Attribute Name Values. In the context of the vector search dialog, the %% around the attribute name are not required, so the following query would also work:

Attribute1 = 'Value'

Compound Queries

Compound attribute queries can be built with logical AND, and OR statements. A compound query would typically use the following syntax:

%Attribute1%='Value' and %Attribute2%='Value 2'

This would find all features that match both Value in Attribute1 and Value 2 in Attribute2.

%Attribute1%='Value' or %Attribute1%='another value'

This query would return all feature that have either value or another value in Attribute 1.

The expression is processed left to right, and the comparison operators return a binary value of 1 for true, and 0 for false. Since each operator is processed independently, the following syntax would not be processed as expected:

1 < %Attribute1% < 5

This expression would be processed the same as (3<%Attribute1%)<5. If 3 is less than the attribute value, the first part will return a 1. If it is greater than the attribute it will return a 0. In either case (0)<5 and (1)<5. This query will always return all features. To find attributes between a certain value, it is necessary to separate the expressions with an AND operator, for example: 

1 < %Attribute1% and %Attribute1% < 5

The NOT operator can be used to negate an expression. For example:

%Attribute1%='Value' and not (%Attribute2%='Value 2')

This would return features that contain Value in attribute1, but do not contain Value 2 in attribute2.

Like queries (with wildcards)

Like queries are used to perform searches on features that match a pattern, rather than necessarily an exact value. The expression can contain the ? and * wildcard characters when using the like operator.

  • ? - Represents a single character wildcard
  • * - Represents a wildcard

Functions

The dropdown list of functions may also be used within a query. The query is run on each feature, and that feature is returned if the query is true (i.e. it matches a boolean value of 1).

A function is run on a number of inputs, which are listed inside of the (). So the basic syntax of a function is like this: 

function(input1, input2, input3)

Each function lists inside of the parenthesis the type of values it expects as input. Those input are manually updated by typing in the query box to fully set up the function.

To see the available functions, select one from the drop down list. A summary of what the selected function does is displayed in the text box below the function list.

To use a function, select it from the list and use the + button to the right of the function list to add it to the expression.

Once the function is added to the query, the descriptors listed inside of the parenthesis need to be replaced with the appropriate input expressions.

For example the function len(string) may be used to search based on the length of an attribute value, rather than the value that it contains:

  • Select the len(string) function from the function list and press the + button to add it to the query.

  • In the Query section of the dialog highlight the string word, so that the placeholder will be replaced with a valid input expression.

  • Use the Attributes list or type into the query to insert the input. In this example the query will determine the length of the <Feature Name> attribute that hold the label for each feature. So the query will read:

    len(<Feature Name>)

  • Expression is interpreted as a boolean value of 0 for false and 1 for true. To make this expression meaning, the length of the feature name could be compared to a value. Type in the query box or use the operators to complete the expression

    len( <Feature Name> ) >10

  • Optionally press the Validate button to make sure that the basic syntax of the query is correct.
  • Press the Search button to perform the search. This example will return all features where the Feature Name is more than 10 characters long.

For more information on the specific functions, see the Formula Calculator.

Default comparison Mode

Comparisons to the Compare Value can be done either textually or numerically.

Automatic- In most cases this will use mathematical operators for input that appear as numbers, and text operators for those that appear like text. In cases of ambiguity, it uses the type of the first operand.

Numeric - Numeric searches should be used with greater than or less than operations when expectation is a quantitative comparison.

For example, with a text search, the value '9 Union St' would be considered greater than the value '700 Middle Street', because it is ordered by the first character. With a numeric search, greater than and less than are based on the quantity, rather than the alphabetical order.

Text -This will perform the comparison based on an alphabetization of the values. For example 'Oceania' is less than 'Seven Seas (open ocean)' in the default countries data because O comes before S in the alphabet.

Make Text Comparisons Case Sensitive - The default mode is to perform case-insensitive queries. [The exception to this is regular expression inside of the Match(), Search(), Find() and Replace() functions, which are case sensitive by default]. Check this option to perform all text string searches in a case sensitive manner. For example, when this option is checked, 'France' would not be equal to 'france'.

To combine a spatial query and an attribute query:

  1. Open the attribute editor and enable the sync.
  2. Use the digitizer selection or advanced selection options to perform a selection by location, or spatial relationships.
  3. Open the vector search tool and setup the query for the attribute search. Check Selected Features in the Feature Options section to search only currently selected features.

Attribute Editor (Search Results) 

The results of the search will display in the Attribute Editor labeled (Search Results) anytime the search is performed on multiple layers.

The attribute list for a particular layer can also be accessed from the Control Center right-click menu Edit Attributes... option. When the search is on multiple layers, the attributes will be sorted alphabetically.

For more information on interacting with the Attribute Editor, see the Attribute Editor