.

フィールド計算機

属性テーブル内の mActionCalculateField フィールド計算機 ボタンを使用すると,既存の属性値または定義された関数にもとづいて計算を実行することができます.例えば地物のジオメトリの長さや面積を計算することができます。計算結果は新しい属性カラムに書き込まれるか既存のカラムの値を上書きします.

ちなみに

仮想フィールド

  • 仮想フィールドはパーマネントではなく保存できません。

  • 仮想フィールドを作成するにはフィールドを作成する際に行います。

The field calculator is now available on any layer that supports edit. When you click on the field calculator icon the dialog opens (see figure_attributes_3). If the layer is not in edit mode, a warning is displayed and using the field calculator will cause the layer to be put in edit mode before the calculation is made.

レイヤが編集可能であれば、属性テーブルの上にあるクイックフィールド演算バーが表示されます。

In quick field calculation bar, you first select the existing field name then open the expression dialog to create your expression or write it directly in the field then click on Update All button.

フィールド計算機ダイアログでは、選択した地物のみを更新するかどうか,計算結果を新しい属性フィールドとして作成するか既存フィールドの更新にするかを選択しなければいけません。

Figure Attributes 3:

../../../_images/fieldcalculator.png

フィールド計算機 nix

新規フィールドの追加を選択した場合フィールド名,フィールドタイプ(integer, real または string),トータルのフィールドの長さとフィールドの精度 (figure_attributes_3 参照) を指定する必要があります.例えば長さが10でフィールドの精度が3を選択するとドットの前に6文字ドットの後に3文字を精度として利用できることを意味します.

短い例ではフィールド計算機の動きを説明しています.ここでは QGIS サンプルデータセットの railroads レイヤの長さをkm単位で計算します:

  1. Load the shapefile railroads.shp in QGIS and press mActionOpenTable Open Attribute Table.
  2. Click on mActionToggleEditing Toggle editing mode and open the mActionCalculateField Field Calculator dialog.
  3. checkbox 新しいフィールドを作る をチェックし,新しいフィールドに計算結果を保存します.

  4. 出力フィールド名として length を追加し,出力フィールドタイプを real, フィールド長を 10,精度を 3に指定します.

  5. Now double click on function $length in the Geometry group to add it into the Field calculator expression box.
  6. フィールド計算機の式ボックスに “/ 1000” と打ち込むと式の完成です.それから [Ok] をクリックして下さい.

  7. 属性テーブルで新規に``length``カラムを見つけることができます。

利用可能な関数は:ref:`vector_expressions`の章にリストされています.