「ベクタプロパティ ダイアログ」の版間の差分

提供: OSGeo.JP Wiki
移動: 案内検索
(Symbology Tab)
(Symbology Tab)
行47: 行47:
  
 
<table align='center'>
 
<table align='center'>
<caption>'''Figure xx:''' Symbolizing-options {{Template:Nix}}</caption>
+
<caption>'''図 9:''' Symbolizing-options {{Template:Nix}}</caption>
 
<tr><td>
 
<tr><td>
   <table align='center'><caption align='bottom'>(x) Single symbol</caption><tr><td><span id='subfig:single_symbol'></span>[[File:vectorClassifySingle.png|296px]]</td></tr></table>
+
   <table align='center'><caption align='bottom'>(a) Single symbol</caption><tr><td><span id='subfig:single_symbol'></span>[[File:vectorClassifySingle.png|296px]]</td></tr></table>
   <table align='center'><caption align='bottom'>(x) Graduated symbol</caption><tr><td><span id='subfig:graduated_symbol'></span>[[File:vectorClassifyGraduated.png|296px]]</td></tr></table><br>
+
   <table align='center'><caption align='bottom'>(b) Graduated symbol</caption><tr><td><span id='subfig:graduated_symbol'></span>[[File:vectorClassifyGraduated.png|296px]]</td></tr></table><br>
   <table align='center'><caption align='bottom'>(x) Continous color</caption><tr><td><span id='subfig:cont_color'></span>[[File:vectorClassifyContinous.png|296px]]</td></tr></table>
+
   <table align='center'><caption align='bottom'>(c) Continous color</caption><tr><td><span id='subfig:cont_color'></span>[[File:vectorClassifyContinous.png|296px]]</td></tr></table>
   <table align='center'><caption align='bottom'>(x) Unique value</caption><tr><td><span id='subfig:unique_val'></span>[[File:vectorClassifyUnique.png|296px]]</td></tr></table>
+
   <table align='center'><caption align='bottom'>(d) Unique value</caption><tr><td><span id='subfig:unique_val'></span>[[File:vectorClassifyUnique.png|296px]]</td></tr></table>
 
</td></tr></table>
 
</td></tr></table>
  

2009年10月4日 (日) 18:12時点における版

The Vector Properties Dialog

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 - either by hand editing the SQL on the General tab or 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 xx: Vector Layer Properties Dialog {{Template:Nix
}caption} VectorLayerSymbology.png

General Tab

The General tab is essentially like that of the raster dialog. It allows you to change the display name, set scale dependent rendering options, create a spatial index of the vector file (only for OGR supported formats and PostGIS) and view or change the projection of the specific vetor layer.

The Query Builder button allows you to create a subset of the features in the layer - but this button currently only is available when you open the attribute table and select the ... button next to Advanced search.

Symbology Tab

QGIS supports a number of symbology renderers to control how vector features are displayed. Currently the following renderers are available:

Single symbol
- a single style is applied to every object in the layer.
Graduated symbol
- objects within the layer are displayed with different symbols classified by the values of a particular field.
Continuous color
- objects within the layer are displayed with a spread of colours classified by the numerical values within a specified field.
Unique value
- objects are classified by the unique values within a specified field with each value having a different symbol.

To change the symbology for a layer, simply double click on its legend entry and the vector Layer Properties dialog will be shown.

図 9: Symbolizing-options Nix.png
(a) Single symbol
VectorClassifySingle.png
(b) Graduated symbol
VectorClassifyGraduated.png

(c) Continous color
VectorClassifyContinous.png
(d) Unique value
VectorClassifyUnique.png


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 mapfeatures.

At least the following styling options apply for nearly all renderers:

Outline style
- pen-style for your outline of your feature. you can also set this to 'no pen'.
Outline color
- color of the ouline of your feature
Outline width
- width of your features
Fill color
- fill-color of your features.
Fill style
- Style for filling. Beside the given brushes you can select Fill style ? texture SelectString.png and click the ... button for selecting your own fill-style. Currently the fileformats *.jpeg, *.xpm, and *.png are supported.

Once you have styled your layer you also could save your layer-style to a separate file (with *.qml-ending). 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 Styel button to revert to your default style.

Vector transparency

QGIS \CURRENT allows to set a transparency for every vector layer. This can be done with the slider Transparency 0% Slider.png inside the symbology tab (see fig. fig:vector_symbology). This is very useful for overlaying several vector layers.

Metadata Tab

The Metadata tab contains information about the layer, including specifics about the type and location, number of features, feature type, and the editing capabilities. The Layer Spatial Reference System section, providing projection information, and the Attribute field info section, listing fields and their data types, are displayed on this tab. This is a quick way to get information about the layer.

Labels Tab

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 labelling the lakes shapefile of the qgis_example_dataset:

  1. Load the Shapefile alaska.shp and GML file lakes.gml in QGIS.
  2. Zoom in a bit to your favorite area with some lake.
  3. Make the lakes layer active.
  4. Open the Layer Properties dialog.
  5. Click on the Labels tab.
  6. Check the CheckBox.pngDisplay labels checkbox to enable labeling.
  7. Choose the field to label with. We'll use Field containing label NAMES SelectString.png.
  8. Enter a default for lakes that have no name. The default label will be used each time QGIS encounters a lake with no value in the NAMES field.
  9. If have labels extending over several lines, check CheckBox.pngMultiline labels?. QGIS will check for a true line return in your label field and insert the line breaks accordingly. A true line return is a single character \n, (not two separate characters, like a backlash \~followed by the character n).
  10. Click Apply.

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:

  1. Click on the Font entry.
  2. Change the placement by selecting one of the radio buttons in the Placement group. To fix our labels, choose the RadioButtonOn.png Right radio button.
  3. the Font size units allows you to select between RadioButtonOn.png Points or RadioButtonOn.png Map units.
  4. Click Apply to see your changes without closing the dialog.

Things are looking better, but the labels are still too close to the marker. To fix this we can use the options on the Position entry. 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:

  1. Click the Buffer tab.
  2. Click the CheckBox.pngBuffer Labels? checkbox to enable buffering.
  3. Choose a size for the buffer using the spin box.
  4. Choose a color by clicking on Color and choosing your favorite from the color selector. You can also set some transparency for the buffer if you prefer.
  5. Click Apply to see if you like the changes.

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 remaining 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.

Not that the Label tab provides a preview-box where your selected label is shown.

Actions Tab

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.

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. 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. 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., {{Template:UserText|[%col10]}). This will prevent the %col10 field name being mistaken for the {{Template:UserText|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: %col1 field name with a テンプレート:Usertext 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: テンプレート:Usertext.

The Identify Results dialog box 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 provided the full path. To be sure, we could rewrite the first example as: {{{1}}}. This will ensure that the konquerorapplication 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 or an

Attribute Table dialog. 

(Recall that these dialogs can be opened by clicking MActionOpenTable.png Identify Features or MActionOpenTable.png Open Table.) 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 Nix.png or perhaps Osx.png ). 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: {{{1}}} , where qgis is the search term. Armed with this information, we can proceed:

  1. Make sure the lakes layer is loaded.
  2. Open the Layer Properties dialog by double-clicking on the layer in the legend or right-click and choose Properties from the popup menu.
  3. Click on the Actions tab.
  4. Enter a name for the action, for example Google Search.
  5. For the action, we need to provide the name of the external program to run. In this case, we can use Firefox. If the program is not in your path, you need to provide the full path.
  6. Following the name of the external application, add the URL used for doing a Google search, up to but not included the search term: {{{1}}}
  7. The text in the Action field should now look like this:
    firefox {{{1}}}
  8. Click on the drop-down box containing the field names for the lakes layer. It's located just to the left of the Insert Field button.
  9. From the drop-down box, select NAMES SelectString.png and click Insert Field.
  10. Your action text now looks like this:
    {{Template:UserText|firefox {{{1}}}
  11. Fo finalize the action click the Insert action button.

This completes the action and it is ready to use. The final text of the action should look like this:

This completes the action and it is ready to use. The final text of the action should look like this:

firefox {{{1}}}

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 xx: Select feature and choose action {{Template:Nix
}caption} Action identifyaction.png

When we click on the action, it brings up Firefox and navigates to the URL {{{1}}} . 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 also invoke actions from the attribute table by selecting a row and right-clicking, then choosing the action from the popup menu.

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.

Attributes Tab

Within the Attributes tab the attributes of the selected dataset can be manipulated. The buttons New Column and Delete Column can be used, when the dataset is in editing mode. At the moment only columns from PostGIS layers can be edited, because this feature is not yet supported by the OGR library.

The Toggle editing mode button toggles this mode.

edit widget

Within the Attributes tab you also find an edit widget and a value column. These two columns can be used to define values or a range of values that are allowed to be added to the specific attribute table columns. They are used to produce different edit widgets in the attribute dialog. These widgets are:

  • line edit: an edit field which allows to enter simple text (or restrict to numbers for numeric attributes).
  • unique value: a list of unique attribute values of all pre-existing features is produced and presented in a combo box for selection.
  • unique value (editable): a combination of `line edit' and `unique value'. The edit field completes entered values to the unique value, but also allows to enter new values.
  • value map: a combobox to select from a set of values specified in the value column the Attributes tab. The possible values are delimited by a semicolon (e.g. high;medium;low). It is also possible to prepend a label to each value, which is delimited with an equal sign (e.g. high=1;medium=2;low=3). The label is shown in the combobox instead of the value.
  • classification: if a unique value renderer is selected for the layer, the values used for the classes are presented for selection in a combobox.
  • range (editable): A edit field that allows to restrict numeric values to a given range. That range is specified by entering minium and maximum value delimited by a semicolon (e.g. 0;360) in the value column of the Attributes tab.
  • range (slider): A slider widget is presented that allows selection of a value in a given range and precision. The range is specifed by minimum, maximum value and a step width (e.g. 0;360;10) in the value column of the Attributes tab.
  • file name: the line edit widget is accompanied by a push button. When pressed it allows to select a filename using the standard file dialog.

Diagram Tab

The Diagram tab allows you to add a grahic overlay to a vector layer. To activate this feature, open the Plugin Manager and select the Diagram Overlay' plugin. After this, there is a new tab in the vector Layer Properties dialog where the settings for diagrams may be entered (see figure~fig:diagramtab).

Figure xx: Vector properties dialog with diagram tab {{Template:Nix
}caption} Diagram tab.png

The current implementation of diagrams provides support for pie- and barcharts and for linear scaling of the diagram size according to a classification attribute. We will demonstrate an example and overlay the alaska boundary layer a barchart diagramm showing some temperature data from a climate vector layer. Both vector layers are part of the QGIS sample dataset (see Section~label_sampledata.

  1. First click on the MActionAddOgrLayer.png Load Vector icon, browse to the QGIS sample dataset folder and load the two vector shape layers alaska.shp and climate.shp.
  2. Double click the climate layer in the map legend to open the Layer Properties dialog.
  3. Click on the Diagram Overlay and select Bar chart as Diagram type.
  4. In the diagram we want to display the values of the three columns T_F_JAN, T_F_JAN and T_F_MEAN. First select T_F_JAN as Attributes and click Add attribute, then T_F_JUL and finally T_F_MEAN.
  5. For linear scaling of the diagram size we define T_F_JUL as classification attribute.
  6. Now click on find maximum value, choose a size value and unit and click Apply to display the diagram in the QGIS main window.
  7. You can now adapt the chart size, or change the attribute colors double clicking on the color values in the attribute field. Figure~fig:climatediagram gives an impression.
  8. Finally click Ok.
Figure xx: Diagram from temperature data overlayed on a map {{Template:Nix
}caption} Climate diagram.png