重要
翻訳は あなたが参加できる コミュニティの取り組みです。このページは現在 59.26% 翻訳されています。
17.5. さらなるアルゴリズムとデータタイプ
注釈
このレッスンでは、さらに3つのアルゴリズムを実行し、他の入力タイプを使用する方法を学習し、出力が指定したフォルダに自動的に保存されるように設定します。
このレッスンにはひとつのテーブルとひとつのポリゴンレイヤが必要です。テーブル内の座標に基づいてポイントレイヤを作成し、各ポリゴン内のポイントの数を数えます。このレッスンに対応するQGISプロジェクト(second_alg)を開くと、XとY座標を持ったテーブルがありますが、ポリゴンレイヤはありませんが心配しないでください。これからプロセシング・ジオアルゴリズムを使って作成します。
The first thing we are going to do is to create a points layer from the coordinates in the table, using the Create points layer from table algorithm. You now know how to use the search box, so it should not be hard for you to find it. Double-click on it to run it and get to its following dialog.
このアルゴリズムは、前のレッスンのようにただ1つの出力を生成し、また、3つの入力を持っています:
テーブル :座標を持つテーブル。ここでレッスンのデータからテーブルを選択する必要があります。
X and Y fields: these two parameters are linked to the first one. The corresponding selector will show the name of those fields that are available in the selected table. Select the
XCOORDfield for the X parameter, and theYCOORDfield for the Y parameter.CRS :このアルゴリズムでは入力レイヤに何も取らないので、それに基づいたCRSを出力レイヤへ割り当てることができません。代わりに、テーブルの座標に使われているCRSを手動で選択するように求められます。左側のボタンをクリックして QGIS CRSセレクタを開き、出力CRSとしてEPSG:4326を選択してください。テーブル内の座標がそのCRSなので、このCRSを使用しています。
ダイアログは次のようになります。
Now press the Run button to get the following layer (you may need to zoom full to reenter the map around the newly created points):
The next thing we need is the polygon layer. We are going to create a regular grid of polygons using the Create grid algorithm, which has the following parameters dialog.
警告
QGISの最近のバージョンではオプションが単純になりました。XとYの最小値と最大値を入力するだけです(推奨値:-5.696226, -5.695122, 40.24742, 40.248171)
グリッドを作成するために必要な入力はすべて数値です。数値を入力する必要がある場合、次の2つのオプションがあります: 対応するボックスに直接入力するか、右にあるボタンをクリックして次のようなダイアログボックスを表示させます。
このダイアログには簡単な計算機が含まれており、 11 * 34.7 + 4.6 のような式を入力すると、計算結果がパラメータダイアログの対応するテキストボックスに入ります。また、それには定数や利用可能な他のレイヤの値も含んでいます。
ここでは入力ポイントレイヤの範囲を覆うグリッドを作成したいので、それらの座標を使い、アルゴリズムがグリッドを作成するのに要するパラメータであるグリッドの中心座標と幅と高さを計算する必要があります。少し数学が必要ですが、計算機ダイアログと入力ポイントレイヤの定数を使って自分でやってみましょう。
Select Rectangles (polygons) in the Grid type field.
最後のアルゴリズムの場合のように、ここにもCRSを入力する必要があります。前に行ったように、ターゲットCRSとしてEPSG:4326を選択します。
最終的に、次のようなパラメータダイアログになるはずです:
(Better add one spacing on the width and height: Horizontal spacing: 0.0001, Vertical spacing: 0.0001, Width: 0.001004, Height: 0.000651, Center X: -5.695674, Center Y: 40.2477955)
The case of X center is a bit tricky, see: -5.696126+(( -5.695222+ 5.696126)/2)
Press Run and you will get the graticule layer.
The last step is to count the points in each one of the rectangles of that graticule. We will use the Count points in polygons algorithm.
これで求めていた結果が得ることができました。
このレッスンを終える前に、データを永続的に保存したい場合に役立つ簡単なヒントを紹介します。全ての出力ファイルを特定のフォルダに保存したい場合、フォルダ名を毎回入力する必要はありません。代わりに、プロセシングメニューに移動し、 オプションと設定 を選択します。すると設定ダイアログが開きます。
In the Output folder entry that you will find in the General group, type the path to your destination folder.
Now when you run an algorithm, just use the filename instead of the full path. For instance, with the configuration shown above, if you enter graticule.shp as the output path for the algorithm that we have just used, the result will be saved in D:processing_outputgraticule.shp. You can still enter a full path in case you want a result to be saved in a different folder.
Try yourself the Create grid algorithm with different grid sizes, and also with different types of grids.