Geography Reference
In-Depth Information
the query. First we add the AND operator by clicking the button in the
Operators section. To add the final parts, just double-click the CAPITAL
field, click the = operator, and double-click Y in the value list. Our query
is now complete:
POPULATION > 2000000 AND CAPITAL = 'Y'
If we test this query, QGIS reports forty-one matching cities. When we
click OK, the attribute table will have those forty-one cities selected. We
can promote them to the top of the table using the Move Selected to Top
button in the Attribute Table toolbar. Since these features are selected,
they will be drawn the map using the selection color preference you
have set in your QGIS preferences or the project properties.
You can construct very complex queries using the query builder. If you
are familiar with SQL, you can bypass the click-and-build routine and
enter the where clause manually. In either case, the ability to define
custom searches is a powerful tool. In a future chapter, we will see how
to use this same concept to create a subset or multiple views of a layer.
Using Attribute Actions
Let's conclude our look at working with attribute data by doing some-
thing useful with the attributes in the cities layer. QGIS has the concept
of attribute actions, in other words, performing some action (think task)
using the value of an attribute. With an attribute action, you can call
another application and pass the value of the attribute to it. Here are
some potential uses for this feature:
• Do a web search based on one or more attribute values.
• Display a photo based on a location stored as a layer attribute.
• Submit values to a URL that creates a report.
• Query a database based on attribute values.
There really is no limit to the way in which you can use actions to
integrate QGIS with other applications and tools. Let's take a simple
example and do a Google search of a city using the results from the
Identify tool. Attribute actions are defined from the Actions tab on the
vector Layer Properties dialog box. The steps to create an action are as
follows:
1. Determine the attribute field(s) needed.
2. Determine the application that will “drive” the action.
3. Construct the argument string using the attribute value(s).
4. Create the action.
 
 
 
Search WWH ::




Custom Search