重要

翻訳は あなたが参加できる コミュニティの取り組みです。このページは現在 66.67% 翻訳されています。

17.15. ラスタレイヤをクリップしてマージする

注釈

このレッスンでは、現実の世界のシナリオで地理アルゴリズムを継続して使用する、空間データの準備の別の例が表示されます。

このレッスンでは、ポリゴン1つだけのベクタレイヤによって与えられる市街地を囲む領域に対して傾斜レイヤを計算しようとしています。ベースDEMは2つのラスタレイヤに分割され、併せると作業したい都市の周りのものよりはるかに大きい領域をカバーしています。このレッスンに対応したプロジェクトを開くと、次のように表示されます。

../../../_images/medfordarea.png

これらのレイヤには二つの問題があります。

  • それらは希望するよりずっと大きい領域をカバーしています(興味があるのは市内中心部の周りのより小さな領域)

  • それらは2つの異なるファイルにあります(市域は1つだけのラスタレイヤに入るが、言われているように、その周りにいくつかの余分な面積が欲しい)。

それらの両方が適切な地理アルゴリズムで簡単に解決できます。

まず、望む領域を定義する矩形を作成します。これを行うには、市の面積の限界を有するレイヤのバウンディングボックスを含むレイヤを作成し、それから厳密に必要であるよりもう少しカバーするラスタレイヤを有するように、それをバッファリングします。

To calculate the bounding box , we can use the Extract layer extent algorithm

../../../_images/bbox.png

To buffer it, we use the Buffer algorithm, with the following parameter values.

../../../_images/buffer_dialog.png

警告

構文は最近のバージョンで変更されました;距離とアークの頂点の両方を0.25に設定します

これが上に示したパラメーターを用いて得られた結果のバウンディングボックスです

../../../_images/buffer.png

It is a rounded box, but we can easily get the equivalent box with square angles, by running the Extract layer extent algorithm on it. We could have buffered the city limits first, and then calculate the extent rectangle, saving one step.

../../../_images/buffer_squared.png

You will notice that the rasters has a different projection from the vector. We should therefore reproject them before proceeding further, using the Warp (reproject) tool.

../../../_images/warp1.png

注釈

最近のバージョンではより複雑なインターフェイスになっています。少なくとも1つの圧縮方式が選択されていることを確認します。

With this layer that contains the bounding box of the raster layer that we want to obtain, we can crop both of the raster layers, using the Clip raster by mask layer algorithm.

../../../_images/clip.png

Once the layers have been cropped, they can be merged using the SAGA Mosaic raster layers algorithm.

../../../_images/merge1.png

注釈

最初にマージしてからトリミングすると時間を節約でき、二回クリッピングアルゴリズムを呼び出さずにすむでしょう。しかしながら、マージする複数のレイヤがあってそれらがかなり大きなサイズを持っている場合、それが後工程に処理が困難であるよりも大きなレイヤになってしまいます。その場合はクリッピングアルゴリズムを数回呼び出す必要があります。時間がかかるかもしれませんが、心配しないで。その操作を自動化するためにいくつかの追加のツールがあることがすぐにわかりますから。この例では、レイヤは2つだけなので、今それを心配することはありません。

それによって、私たちが望む最後のDEMが得られます。

../../../_images/finaldem.png

では傾斜レイヤを計算しましょう。

A slope layer can be computed with the Slope algorithm, but the DEM obtained in the last step is not suitable as input, since elevation values are in meters but cellsize is not expressed in meters (the layer uses a CRS with geographic coordinates). A reprojection is needed. To reproject a raster layer, the Warp (reproject) algorithm can be used again. We reproject into a CRS with meters as units (e.g. 3857), so we can then correctly calculate the slope, with either SAGA or GDAL.

新DEMでは、傾きが計算できるようになりました。

../../../_images/slope1.png

そして、これが結果の傾斜レイヤです。

../../../_images/slopereproj.png

The slope produced by the Slope algorithm can be expressed in degrees or radians; degrees are a more practical and common unit. In case you calculated it in radians, the Metric conversions algorithm will help us to do the conversion (but in case you didn't know that algorithm existed, you could use the raster calculator that we have already used).

../../../_images/metricconversions.png

Reprojecting the converted slope layer back with the Reproject raster layer, we get the final layer we wanted.

再投影プロセスでは、最初のステップの1つで計算されたバウンディングボックス外のデータを最終レイヤが格納するようにしている可能性があります。これは、ベースDEMを得るためにしたのと同じように、それを再びクリッピングすることによって解決できます。