The Layer Properties dialog for a vector layer provides information about the layer, symbology settings and labeling options. If your vector layer has been loaded from a PostgreSQL/PostGIS datastore, you can also alter the underlying SQL for the layer by invoking the Query Builder dialog on the General tab. To access the Layer Properties dialog, double-click on a layer in the legend or right-click on the layer and select Properties from the popup menu.
Figure Vector Properties 1:
QGIS 1.4.0 から新しいシンボロジーが平行して導入され,最終的には古いシンボロジーを置き換えられます. QGIS 1.8 では多彩な進化や機能が提供されている新しいシンボロジーがデフォルトで利用されてます.
古いシンボロジーについては Old Symbology の節で説明されています.
3種類のシンボルがあります:マーカーシンボル(ポイント用),ラインシンボル(ライン用)と塗りつぶしとアウトライン洋シンボル(ポリゴン用)です.シンボルは1個またはそれ以上のシンボルレイヤを構成できます.いくつかのレイヤは色が固定されています-それらの色は変更できません.このことはマルチレイヤシンボルを定義するときに便利です.マーカーシンボルのサイズと角度を定義できるのと同じようにラインシンボルの幅を定義できます.
利用可能なシンボルレイヤタイプ
ポイントレイヤ
フォントマーカー: フォントを使った描画.
シンプルマーカー: ハードコーディングされたマーカーによる描画.
SVGマーカー: SVG ピクチャを使った描画.
楕円マーカー: 属性値を利用して楕円で描画を行う.
ベクタフィールドマーカーr: 属性値で提供されるベクタフィールドの値で描画する.
ラインレイヤ
ライン整飾: ラインに整飾を加える, 例えばラインの方向を示す矢印.
マーカーライン: マーカーシンボルが繰り返し描画されるライン.
シンプルライン: 普通の描画方法のライン (幅 色 ペンスタイルの指定).
ポリゴンレイヤ
セントロイド塗りつぶし: ポリゴンセントロイドをハードコーディングマーカーで塗りつぶします.
SVG 塗りつぶし: ポリゴンを SVG シンボルで塗りつぶします.
シンプル塗りつぶし: ポリゴンの通常の描画方法です (塗りつぶし色,パターンとアウトラインの指定).
** ラインパターン塗りつぶし**: ポリゴンをラインパターンで塗りつぶします.
ポイントパターン塗りつぶし: ポリゴンをポイントパターンで塗りつぶします.
アウトライン:ライン整飾: ラインに整飾を加えます, 例えばラインの方向を示す矢印.
アウトライン: マーカーライン: ハードコーディングされたマーカーをアウトラインエリアとして使います.
アウトライン:シンプルライン: 幅 色 ペンスタイルを指定するアウトライン.
カラーランプ
カラーランプはレンダラ作成のために色の範囲を定義するのに使われます.このシンボルの色はカラーランプから設定されます.
3種類のカラーランプタイプがあります:
階調:1色からいくつかの他の色での線形グラデーション。
ランダム:カラースペースの指定されたエリアからランダムに生成された色。
ColorBrewer: 色のスキーマから色のエリアと色の階級数の定義を作成します。
カラーランプは **[追加]**ボタンをクリックし :guilabel:`スタイルマネージャ`の :guilabel:`カラーランプ`タブで定義でき、カラーランプタイプを選択できます(vector_style_manager セクションを参照)。
スタイル
A style groups a set of various symbols and color ramps. You can define
your prefered or frequently used symbols, and can use it without having
to recreate it everytime. Style items (symbols and color ramps) have always
a name by which they can be queried from the style. There is at least one
default style in QGIS (modifiable) and the user can add further styles.
In the lower part of the Style tab there are four buttons for managing styles:
Use [Restore Default Style] to get back to your default settings, [Save As Default]
to save your style as default, [Load Style...] to get to your own styles and
[Save Style] to save your own styles. Layer styles can also be transferred
from one layer to another layer. Activate a layer and choose Layer ‣
Copy style and switch to another layer. Then choose
Layer ‣
Paste style.
レンダラ
The renderer is responsible for drawing a feature together with the correct symbol. There are four types of renderers: single symbol, categorized (called unique color in the old symbology), graduated and rule-based. There is no continuous color renderer, because it is in fact only a special case of the graduated renderer. The categorized and graduated renderer can be created by specifying a symbol and a color ramp - they will set the colors for symbols appropriately.
新世代シンボロジーで作業をする
In the Style tab you can choose one of the five renderers: single symbol, categorized, graduated, rule-based and point displacement. For each data type (points, lines and polygons) vector symbol layer types are available (see vector_symbol_types). Depending on the chosen renderer, the symbology Depending on the chosen renderer, the Style tab provides different following sections. The new generation symbology dialog also provides a [Style Manager] button which gives access to the Style Manager (see Section Style Manager). The Style Manager allows you to edit and remove existing symbols and add new ones.
ちなみに
複数シンボルを選択して変更する
The New Generation Symbology allows to select multiple symbols and right click to change color, transparency, size, or width of selected entries.
単一シンボルレンダラ
The Single Symbol Renderer is used to render all features of the layer using a single user-defined symbol. The properties, that can be adjusted in the Style tab, depend partially on the type of the layer, but all types share the following structure. In the top left part of the tab, there is a preview of the current symbol to be rendered. In the bottom part of the tab, there is a list of symbols already defined for the current style, prepared to be used via selecting them from the list. The current symbol can be modified using the [Change] button below the preview, which opens a Symbol Properties dialog, or the [Change] button right of the preview, which opens an ordinary Color dialog.
Figure Symbology 1:
In the Style tab you can apart from a general layer transparency also define to use millimeter or map units for the size scale. In the [Advanced] button next to the [Save as style] button you can use data-defined size scale and rotation. Here the Symbol levels ‣ menu allows to enable and define the order in which the symbol layers are rendered (if the symbol consists of more than one layer).
After having done any needed changes, the symbol can be added to the list of current style symbols (using the [Save as style] button) and then easily be used in the future. Furthermore you can use the [Save Style] button to save the symbol as a QGIS layer style file (.qml) or SLD file(.sld). Currently in version 1.8 SLDs can be exported from any type of renderer: single symbol, categorized, graduated or rule-based, but when importing an SLD, either a single symbol or rule-based renderer is created. That means that categorized or graduated styles are converted to rule-based. If you want to preserve those renderers, you have to stick to the QML format. On the other hand, it could be very handy sometimes to have this easy way of converting styles to rule-based.
Categorized Renderer
The Categorized Renderer is used to render all features from a layer, using a single user-defined symbol, which color reflects the value of a selected feature’s attribute. The Style tab allows you to select:
The [Advanced] button in the lower right corner of the dialog allows to set the fields containing rotation and size scale information. For convenience, the list in the bottom part of the tab lists the values of all currently selected attributes together, including the symbols that will be rendered.
The example in figure_symbology_2 shows the category rendering dialog used for the rivers layer of the QGIS sample dataset.
Figure Symbology 2:
You can create a custom color ramp choosing New color ramp... from the Color ramp dropdown menu. A dialog will prompt for the ramp type: Gradient, Random, ColorBrewer, then each one has options for number of steps and/or multiple stops in the color ramp. See figure_symbology_3 for an example of custom color ramp.
Figure Symbology 3:
Graduated Renderer
The Graduated Renderer is used to render all the features from a layer, using a single user-defined symbol, whose color reflects the classification of a selected feature’s attribute to a class.
Figure Symbology 4:
Like Categorized Renderer, it allows to define rotation and size scale from specified columns.
Analogue to the categorized rendered, the Style tab allows you to select:
Additionally, you can specify the number of classes and also the mode how to classify features inside the classes (using the Mode list). The available modes are:
The listbox in the bottom part of the Style tab lists the classes together with their ranges, labels and symbols that will be rendered.
The example in figure_symbology_4 shows the graduated rendering dialog for the rivers layer of the QGIS sample dataset.
Rule-based rendering
The rule-based renderer is used to render all the features from a layer, using rule based symbols, whose color reflects the classification of a selected feature’s attribute to a class. The rules are based on SQL statements. The dialog allows rule grouping by filter or scale and you can decide if you want to enable symbol levels or use only first matched rule.
The example in figure_symbology_5 shows the rule-based rendering dialog for the rivers layer of the QGIS sample dataset.
To create a rule, activate an existing row by clicking on it or click on ‘+’ and
click on the new rule. Then press the [Edit] button. In the Rule
properties dialog you can define a label for the rule. Press the
button to open the Expression builder. In the Function List, click on
Fields and Values to view all attributes of the attribute table to
be searched. To add an attribute to the Field calculator Expression field,
double click its name in the Fields and Values list. Generally you
can use the various fields, values and functions to construct the calculation
expression or you can just type it into the box (see フィールド演算).
Figure Symbology 5:
Point displacement
The point displacement renderer offers to visualize all features of a point layer, even if they have the same location. To do this, the symbols of the points are placed on a displacement circle around a center symbol.
Figure Symbology 6:
Symbol Properties
The symbol properties dialog allows the user to specify different properties
of the symbol to be rendered. In the bottom left part of the dialog, you find
a preview of the current symbol as it will be displayed in the map canvas.
Above the preview is the list of symbol layers. To start the Symbol
properties dialog, click the [ Change...] button in
the Style tab of the Layer Properties dialog.
The buttons allow adding or removing layers, changing the position of layers, or
locking layers for color changes. In the right part of the dialog, there are
shown the settings applicable to the single symbol layer selected in the symbol
layer list. The most important is the Symbol Layer Type
combobox, which allows you to choose the layer type. The available options depend
on the layer type (Point, Line, Polygon). The symbol layer type options are
described in section vector_symbol_types. You can also change the symbol
layer properties in the right part of the dialog. For example if you have chosen
an SVG marker for a point layer it is now possible to change its color using
Color button.
Figure Symbology 7:
The Style Manager is a small helper application, that lists symbols and color ramps available in a style. It also allows you to add and/or remove items. To launch the Style Manager, click on Settings ‣ Style Manager in the main menu. Alternatively, you can access it via the Style tab.
Figure Symbology 10:
ノート
QGIS 1.8. still supports the usage of the old symbology, although it is recommended to switch to the new symbology, described in section vector_new_symbology, because the old symbology will be removed in one of the next releases.
If you want or need to switch back to the old symbology you can click on the [Old symbology] button in the Style tab of the Layer Properties dialog.
You can also make the old symobolgy the default, deactivating
Use new generation symbology for rendering in the
Rendering tab under Settings ‣
Options.
The old QGIS symbology supports the following renderers:
To change the symbology for a layer, simply double click on its legend entry and the vector Layer Properties dialog will be shown.
Style Options
Within this dialog you can style your vector layer. Depending on the selected rendering option you have the possibility to also classify your map features.
At least the following styling options apply for nearly all renderers:
Once you have styled your layer you also could save your layer-style to a separate file (ending with *.qml). To do this, use the button [Save Style...]. No need to say that [Load Style...] loads your saved layer-style-file.
If you wish to always use a particular style whenever the layer is loaded, use the [Save As Default] button to make your style the default. Also, if you make changes to the style that you are not happy with, use the [Restore Default Style] button to revert to your default style.
Vector transparency
QGIS allows to set a transparency for every vector layer. This can be done
with the slider Transparency inside the
Style tab. This is very useful for overlaying several vector
layers.
As for the symbology QGIS 1.8 currently provides an old and a new labeling
engine in parallel. The Labels tab still contains the old labeling.
The new labeling is implemented as a core application and will replace the features
of the old labels tab in one of the next versions.
We recommend to switch to the new labeling, described in section New Labeling.
The old labeling in the Labels tab allows you to enable labeling features and control a number of options related to fonts, placement, style, alignment and buffering. We will illustrate this by labeling the lakes shapefile of the QGIS sample dataset:
Now we have labels. How do they look? They are probably too big and poorly placed in relation to the marker symbol for the lakes.
Select the Font entry and use the [Font] and [Color] buttons to set the font and color. You can also change the angle and the placement of the text-label.
To change the position of the text relative to the feature:
Things are looking better, but the labels are still too close to the marker. To fix this we can use the options on the Offset entry which is on the bottom of the menu. Here we can add offsets for the X and Y directions. Adding an X offset of 5 will move our labels off the marker and make them more readable. Of course if your marker symbol or font is larger, more of an offset will be required.
The last adjustment we’ll make is to Buffer the labels. This just means putting a backdrop around them to make them stand out better. To buffer the lakes labels:
If you aren’t happy with the results, tweak the settings and then test again by clicking [Apply].
A buffer of 1 points seems to give a good result. Notice you can also specify the buffer size in map units if that works out better for you.
The advanced entries inside the Label tab allow you control the appearance of the labels using attributes stored in the layer. The entries beginning with Data defined allow you to set all the parameters for the labels using fields in the layer.
Note that the Label tab provides a preview-box where your selected label is shown.
The new Labeling core application provides smart
labeling for vector point, line and polygon layers and only requires a
few parameters. This new application will replace the current QGIS labeling,
described in section Labels Tab and also supports on-the-fly
transformated layers.
Using new labeling
Labeling point layers
First step is to activate the Label this layer checkbox
and select an attribute column to use for labeling. Click
if you
want to define labels based on expressions. After that you can define the text
style and the scale-based visibility in the Label settings tab (see
Figure_labels_1 ). Choose the Advanced tab for the label placement
and the labeling priority. You can define if every part of a multipart feature
is to be labeled here. With the wrap label on character function you can define
a character for a line break in the labels. The Data defined settings
tab provides you with the attribute-based definition of Font properties, Buffer
properties and Position.
Figure Labels 1:
Labeling line layers
First step is to activate the Label this layer checkbox
in the Label settings tab and select an attribute column to use for
labeling. Here you can also define labels based on expressions. After that you
can define the text style and the scale-based visibility. Further labeling options
are available through the Advanced tab. You can define the label
placement and label distance, a line orientation dependend position and the
labeling priority here. Furthermore you can define if every part of a multipart
line is to be labeled, if lines shall be merged to avoid duplicate labels and if
a direction symbol is added (see Figure_labels_2 ). It is also possible to
supress labeling of features and wrap lables on characters. Use Data
defined settings for attribute-based or database-connection-based settings.
Figure Labels 2:
Labeling polygon layers
First step is to activate the Label this layer checkbox
and select an attribute column to use for labeling. Here you can also define
labels based on expressions. In Label settings define the text style
and the scale-based visibility (see Figure_labels_3 ). Use the Advanced
tab for label placement, label distance and labeling priority. Define if every
part of a multipart feature is to be labeled, suppress labeling of features and
wrap labels on characters here. Use Data defined settings for
attribute-based or database-connection-based settings.
Figure Labels 3:
Change engine settings
Additionally you can click the [Engine settings] button and select the search method, used to find the best label placement. Available is Chain, Popmusic Tabu, Popmusic Chain, Popmusic Tabu Chain and FALP.
Figure Labels 4:
Furthermore the number of candidates can be defined for point, line and polygon features, and you can define whether to show all labels (including colliding labels) and label candidates for debugging.
Keywords to use in attribute columns for labeling
There is a list of supported key words, that can be used for the placement of labels in defined attribute columns.
A combination of key words in one column also works, e.g.: base right or bottom left.
Within the Fields tab the field attributes of the
selected dataset can be manipulated. The buttons
New Column and
Delete Column
can be used, when the dataset is
Editing mode.
At the moment only columns from PostGIS layers can be removed and added. The OGR library supports to add and remove columns, if you have a GDAL version >= 1.9 installed.
Edit Widget
Figure Fields 1:
Within the Fields tab you also find an edit widget column. This column can be used to define values or a range of values that are allowed to be added to the specific attribute table column. If you click on the [edit widget] button, a dialog opens, where you can define different widgets. These widgets are:
The General tab is essentially like that of the raster dialog.
There are several options available:
Furthermore you can activate and set Use scale
dependent rendering, define provider specific options (e.g. encoding) and with the
[Query Builder] button you can create a subset of the features in the layer
that will be visualized (also refer to section 選択).
Figure General 1:
The Metadata tab contains general information about the layer,
including specifics about the type and location, number of features, feature
type, and the editing capabilities. The Extents section, providing
layer extent information, and the Layer Spatial Reference System
section, providing information about the CRS of the layer. This is a quick way
to get information about the layer.
Additionally you can add/edit a title for the layer and some abtract information. These information will be saved in the QGIS project file for following sessions and will be used for QGIS server.
Figure Metadata 1:
QGIS provides the ability to perform an action based on the attributes
of a feature. This can be used to perform any number of actions, for example,
running a program with arguments built from the attributes of a feature or
passing parameters to a web reporting tool.
Figure Actions 1:
Actions are useful when you frequently want to run an external application or view a web page based on one or more values in your vector layer. They are devided into 6 types and can be used like this:
There are several examples included in the dialog. You can load them clicking on [Add default actions]. An example is performing a search based on an attribute value. This concept is used in the following discussion.
Defining Actions
Attribute actions are defined from the vector Layer Properties dialog. To define an action, open the vector Layer Properties dialog and click on the Actions tab. Select ‘Generic’ as type and provide a descriptive name for the action. The action itself must contain the name of the application that will be executed when the action is invoked. You can add one or more attribute field values as arguments to the application. When the action is invoked any set of characters that start with a % followed by the name of a field will be replaced by the value of that field. The special characters %% will be replaced by the value of the field that was selected from the identify results or attribute table (see using_actions below). Double quote marks can be used to group text into a single argument to the program, script or command. Double quotes will be ignored if preceded by a backslash.
If you have field names that are substrings of other field names (e.g., col1 and col10) you should indicate so, by surrounding the field name (and the % character) with square brackets (e.g., [%col10]). This will prevent the %col10 field name being mistaken for the %col1 field name with a 0 on the end. The brackets will be removed by QGIS when it substitutes in the value of the field. If you want the substituted field to be surrounded by square brackets, use a second set like this: [[%col10]].
Using the Identify Features tool you can open Identify Results dialog. It includes a (Derived) item that contains information relevant to the layer type. The values in this item can be accessed in a similar way to the other fields by using preceeding the derived field name by (Derived).. For example, a point layer has an X and Y field and the value of these can be used in the action with %(Derived).X and %(Derived).Y. The derived attributes are only available from the Identify Results dialog box, not the Attribute Table dialog box.
Two example actions are shown below:
In the first example, the web browser konqueror is invoked and passed a URL to open. The URL performs a Google search on the value of the nam field from our vector layer. Note that the application or script called by the action must be in the path or you must provide the full path. To be sure, we could rewrite the first example as: /opt/kde3/bin/konqueror http://www.google.com/search?q=%nam. This will ensure that the konqueror application will be executed when the action is invoked.
The second example uses the %% notation which does not rely on a particular field for its value. When the action is invoked, the %% will be replaced by the value of the selected field in the identify results or attribute table.
Using Actions
Actions can be invoked from either the Identify Results dialog,
an Attribute Table dialog or from Run Feature Action
(recall that these dialogs can be opened by clicking
Identify Features or
Open Attribute Table or
Run Feature Action). To invoke an action, right
click on the record and choose the action from the popup menu. Actions are
listed in the popup menu by the name you assigned when defining the actions.
Click on the action you wish to invoke.
If you are invoking an action that uses the %% notation, right-click on the field value in the Identify Results dialog or the Attribute Table dialog that you wish to pass to the application or script.
Here is another example that pulls data out of a vector layer and inserts
them into a file using bash and the echo command (so it will only work
or perhaps
). The layer in question has fields for a species name
taxon_name, latitude lat and longitude long. I would like to be
able to make a spatial selection of a localities and export these field values
to a text file for the selected record (shown in yellow in the QGIS map area).
Here is the action to achieve this:
bash -c "echo \"%taxon_name %lat %long\" >> /tmp/species_localities.txt"
After selecting a few localities and running the action on each one, opening the output file will show something like this:
Acacia mearnsii -34.0800000000 150.0800000000
Acacia mearnsii -34.9000000000 150.1200000000
Acacia mearnsii -35.2200000000 149.9300000000
Acacia mearnsii -32.2700000000 150.4100000000
As an exercise we create an action that does a Google search on the lakes layer. First we need to determine the URL needed to perform a search on a keyword. This is easily done by just going to Google and doing a simple search, then grabbing the URL from the address bar in your browser. From this little effort we see that the format is: http://google.com/search?q=qgis, where QGIS is the search term. Armed with this information, we can proceed:
This completes the action and it is ready to use. The final text of the action should look like this:
firefox http://google.com/search?q=%NAMES
We can now use the action. Close the Layer Properties dialog and zoom in to an area of interest. Make sure the lakes layer is active and identify a lake. In the result box you’ll now see that our action is visible:
Figure Actions 2:
When we click on the action, it brings up Firefox and navigates to the URL http://www.google.com/search?q=Tustumena. It is also possible to add further attribute fields to the action. Therefore you can add a + to the end of the action text, select another field and click on [Insert Field]. In this example there is just no other field available that would make sense to search for.
You can define multiple actions for a layer and each will show up in the Identify Results dialog.
You can think of all kinds of uses for actions. For example, if you have a point layer containing locations of images or photos along with a file name, you could create an action to launch a viewer to display the image. You could also use actions to launch web-based reports for an attribute field or combination of fields, specifying them in the same way we did in our Google search example.
We can also make more complex examples, for instance on how to use Python actions.
Usually when we create an action to open a file with an external application we can use absolute paths, or eventually relative paths, in the second case the path is relative to the location of the external program executable file. But what about we need to use relative paths, relative to the selected layer (a file based one, like a shapefile or spatialite)? The following code will do the trick:
command = "firefox";
imagerelpath = "images_test/test_image.jpg";
layer = qgis.utils.iface.activeLayer();
import os.path;
layerpath = layer.source() if layer.providerType() == 'ogr' else \
(qgis.core.QgsDataSourceURI(layer.source()).database() \
if layer.providerType() == 'spatialite' else None);
path = os.path.dirname(str(layerpath));
image = os.path.join(path,imagerelpath);
import subprocess;
subprocess.Popen( [command, image ] );
we have to just remember that the action is one of type Python and to change the command and imagerelpath variables to fit our needs.
But what about if the relative path need to be relative to the (saved) project file? The code of the Python action would be:
command="firefox";
imagerelpath="images/test_image.jpg";
projectpath=qgis.core.QgsProject.instance().fileName();
import os.path; path=os.path.dirname(str(projectpath)) \
if projectpath != '' else None;
image=os.path.join(path, imagerelpath);
import subprocess;
subprocess.Popen( [command, image ] );
Another Python actions example if the one that allows us to add new layers to the project. For instance the following examples will add to the project respectively a vector and a raster. The name of files to be added to the project and the name to be given to the layer are data driven (filename and layname are column names of the table of attributes of the vector where the action was created):
qgis.utils.iface.addVectorLayer('/yourpath/[% "filename" %].shp','[% "layername" %]', 'ogr')
To add a raster (a tif image in this example) it becomes:
qgis.utils.iface.addRasterLayer('/yourpath/[% "filename" %].tif','[% "layername" %]')
The Joins tab allows you to join a loaded attribute table
to a loaded vector layer. As key columns you have to define a join
layer, a join field and a target field. QGIS currently supports to join non
spatial table formats supported by OGR, delimited text and the PostgreSQL
provider (see figure_joins_1).
Figure Joins 1:
Additionally the add vector join dialog allows to:
The Diagrams tab allows you to add a graphic overlay to a
vector layer (see figure_diagrams_1).
The current core implementation of diagrams provides support for piecharts and text diagrams. Text values of different data columns are displayed one below the other with a circle or a box and dividers. Diagram size is based on a fixed size or on linear scaling according to a classification attribute. The placement of the diagrams interacts with the new labeling, so position conflicts between diagrams and labels are detected and solved. In addition to chart positions can be fixed by the users hand.
Figure Diagrams 1:
We will demonstrate an example and overlay the alaska boundary layer a text diagram showing some temperature data from a climate vector layer. Both vector layers are part of the QGIS sample dataset (see Section サンプルデータ).
Figure Diagrams 2:
Additionally in the Settings ‣ Options dialog, there is a Overlay tab where it is possible to select the placement algorithm of the diagrams. The central point method is a generic one, the others use algorithms of the PAL library. They also consider diagram objects and labels in different layers. Also see section Diagram Overlay Plugin for additional diagram features.