7.2. Lesson: ベクター分析

ベクターデータも分析でき、さまざまな地物が空間内でどのように相互作用するかを明らかにできます。GISには多くの異なった分析関連機能があるので、それらすべてを見ていくことはしません。むしろ、問題を提起し、それをQGISが提供するツールを使用して解決しようと試みるつもりです。

このレッスンの目標: 質問を尋ね、分析ツールを使ってそれを解決すること。

7.2.1. basic GISプロセス

始める前に、任意のGISの問題を解決するために使用できるプロセスの簡単な概要を与えることが有用でしょう。それを行う方法は次のとおりです。

  1. 問題の状態

  2. データの入手

  3. 問題の分析

  4. 結果のプレゼン

7.2.2. basic The Problem

解決する問題を決定することから手順を開始しましょう。たとえば、不動産業者が以下の基準を持っている顧客のために Swellendam にある居住用の不動産を探しています:

  1. It needs to be in Swellendam

  2. It must be within reasonable driving distance of a school (say 1km)

  3. It must be more than 100m squared in size

  4. Closer than 50m to a main road

  5. Closer than 500m to a restaurant

7.2.3. basic The Data

これらの疑問に答えるため、次のデータが必要になるでしょう:

  1. The residential properties (buildings) in the area

  2. The roads in and around the town

  3. The location of schools and restaurants

  4. The size of buildings

All of this data is available through OSM and you should find that the dataset you have been using throughout this manual can also be used for this lesson.

If you want to download data from another area jump to Introduction Chapter section to read how to do it.

注釈

OSMのダウンロードは一貫したデータフィールドを持っていますが、範囲と詳細は多様になってしまいます。たとえば選択した領域にレストランについての情報が含まれていないとわかった場合は、別の地域を選択することが必要な場合があります。

7.2.4. basic Follow Along: Start a Project and get the Data

We first need to load the data to work with.

  1. Start a new QGIS project

  2. If you want you can add a background map. Open the Browser and load the OSM background map from the XYZ Tiles menu.

    ../../../_images/osm_swellendam.png
  3. In the training_data.gpkg Geopackage database load all the files we will use in this chapter:

    1. landuse

    2. buildings

    3. roads

    4. restaurants

    5. schools

  4. Zoom to the layer extent to see Swellendam, South Africa

Before proceeding we should filter the roads layer in order to have only some specific road types to work with.

Some of the roads in OSM dataset are listed as unclassified, tracks, path and footway. We want to exclude these from our dataset and focus on the other road types, more suitable for this exercise.

Moreover, OSM data might not be updated everywhere and we will also exclude NULL values.

  1. Right click on the roads layer and choose Filter....

  2. In the dialog that pops up we can filter these features with the following expression:

    "highway" NOT IN ('footway','path','unclassified','track') OR "highway" != NULL
    

    The concatenation of the two operators NOT and IN means to exclude all the unwanted features that have these attributes in the highway field.

    != NULL combined with the OR operator is excluding roads with no values in the highway field.

    You will note the indicatorFilter icon next to the roads layer that helps you remember that this layer has a filter activated and not all the features are available in the project.

The map with all the data should look like the following one:

../../../_images/osm_swellendam_2.png

7.2.5. basic Try Yourself レイヤーCRSの変換

Because we are going to be measuring distances within our layers, we need to change the layers' CRS. To do this, we need to select each layer in turn, save the layer to a new one with our new projection, then import that new layer into our map.

You have many different options, e.g. you can export each layer as a new Shapefile, you can append the layers to an existing GeoPackage file or you can create another GeoPackage file and fill it with the new reprojected layers. We will show the last option so the training_data.gpkg will remain clean. But feel free to choose the best workflow for yourself.

注釈

この例では、 WGS 84 / UTMゾーン34S CRSを使用していますが、お住まいの地域のためのより適切なUTM CRSを使用できます。

  1. Right click the roads layer in the Layers panel;

  2. Click Export --> Save Features As...;

  3. In the Save Vector Layer As dialog choose GeoPackage as Format;

  4. Click on ... of File name parameter and name the new GeoPackage as vector_analysis;

  5. Change the Layer name as roads_34S;

  6. Change the CRS parameter to WGS 84 / UTM zone 34S;

  7. Finally click on OK:

    ../../../_images/save_roads_34S.png

    This will create the new GeoPackage database and fill it with the roads_34S layer.

  8. Repeat this process for each layer, creating a new layer in the vector_analysis.gpkg GeoPackage file with _34S appended to the original name and removing each of the old layers from the project.

    注釈

    When you choose to save a layer to an existing GeoPackage, QGIS will append that layer in the GeoPackage.

  9. それぞれのレイヤーに対してプロセスが完了したら、いずれかのレイヤーの上で右クリックして、 レイヤー範囲にズーム をクリックして関心領域に地図を集中してください。

今、UTM投影にOSMのデータを変換したので、計算を開始できます。

7.2.6. basic Follow Along: 問題の分析:学校と道路からの距離

QGISではどんなベクターからの距離も計算できます。

  1. Make sure that only the roads_34S and buildings_34S layers are visible, to simplify the map while you're working

  2. Click on the Processing ‣ Toolbox to open the analytical core of QGIS. Basically: all algorithms (for vector and raster) analysis are available within this toolbox.

  3. We start by calculating the area around the roads_34S by using the Buffer algorithm. You can find it expanding the Vector Geometry group.

    ../../../_images/processing_buffer_1.png

    Or you can type buffer in the search menu in the upper part of the toolbox:

    ../../../_images/processing_buffer_2.png
  4. Double click on it to open the algorithm dialog

  5. Set it up like this

    ../../../_images/vector_buffer_setup.png
  6. The default Distance is in meters because our input dataset is in a Projected Coordinate System that uses meter as its basic measurement unit. You can use the combo box to choose other projected units like kilometers, yards, etc.

    注釈

    If you are trying to make a buffer on a layer with a Geographical Coordinate System, Processing will warn you and suggest to reproject the layer to a metric Coordinate System.

  7. By default Processing creates temporary layers and adds them to the Layers panel. You can also append the result to the GeoPackage database by:

    1. clicking on the ... button and choose Save to GeoPackage...

    2. naming the new layer roads_buffer_50m

    3. and saving it in the vector_analysis.gpkg file

    ../../../_images/buffer_saving.png
  8. Click on Run and then close the Buffer dialog.

地図は次のようになっているでしょう:

../../../_images/roads_buffer_result.png

If your new layer is at the top of the Layers list, it will probably obscure much of your map, but this gives you all the areas in your region which are within 50m of a road.

However, you'll notice that there are distinct areas within your buffer, which correspond to all the individual roads. To get rid of this problem:

  1. Uncheck the roads_buffer_50m layer and re-create the buffer using the settings shown here:

    ../../../_images/dissolve_buffer_setup.png

    Note that we're now checking the Dissolve result box

  2. Save the output as roads_buffer_50m_dissolved

  3. Click Run and close the Buffer dialog again

Once you've added the layer to the Layers panel, it will look like this:

../../../_images/dissolve_buffer_results.png

今不要な下位区分はありません。

注釈

The Short Help on the right side of the dialog explains how the algorithm works. If you need more information, just click on the Help button in the bottom part to open a more detailed guide of the algorithm.

7.2.7. basic Try Yourself 学校からの距離

上記と同じアプローチを使用し、学校のためのバッファを作成します。

It needs to be 1 km in radius. Save the new layer in the vector_analysis.gpkg file as schools_buffer_1km_dissolved.

結果の確認

7.2.8. basic Follow Along: 重複エリア

Now we have areas where the road is 50 meters away and there's a school within 1 km (direct line, not by road). But obviously, we only want the areas where both of these criteria are satisfied. To do that, we'll need to use the Intersect tool. You can find it in Vector Overlay group within Processing ‣ Toolbox.

  1. このように設定します:

    ../../../_images/school_roads_intersect.png
    • The input layers are the two buffers

    • The saving location is, once again, the vector_analysis.gpkg GeoPackage

    • And the output layer name is road_school_buffers_intersect

  2. Click Run.

    下の画像で、青色の領域が両方の距離基準が一度に満たされている場所を示しています!

    ../../../_images/intersect_result.png
  3. 2つのバッファレイヤーを除去しそれらが重なる場所を示すものだけ残しても良いです。それがそもそも本当に知りたかったものですので:

    ../../../_images/final_intersect_result.png

7.2.9. basic Follow Along: Extract the Buildings

Now you've got the area that the buildings must overlap. Next, you want to extract the buildings in that area.

  1. Look for the menu entry Vector Selection ‣ Extract by location within Processing ‣ Toolbox

  2. Set up the algorithm dialog like in the following picture

    ../../../_images/location_select_dialog.png
  3. Click Run and then close the dialog

  4. You'll probably find that not much seems to have changed. If so, move the well_located_houses layer to the top of the layers list, then zoom in.

    ../../../_images/select_zoom_result.png

    The red buildings are those which match our criteria, while the buildings in green are those which do not.

  5. Now you have two separated layers and can remove buildings_34S from layer list.

7.2.10. moderate Try Yourself さらに建物をフィルタ

今、私たちの学校の1キロ内や道路の50メートル内のすべての建物を表示するレイヤーを持っています。今その選択を、レストランの500メートル内にある建物を表示するだけに削減する必要があります。

Using the processes described above, create a new layer called houses_restaurants_500m which further filters your well_located_houses layer to show only those which are within 500m of a restaurant.

結果の確認

7.2.11. basic Follow Along: 正しいサイズの建物の選択

To see which buildings are of the correct size (more than 100 square meters), we first need to calculate their size.

  1. Select the houses_restaurants_500m layer and open the Field Calculator by clicking on the calculateField button in the main toolbar or within the attribute table

  2. Set it up like this

    ../../../_images/buildings_area_calculator.png

    We are creating the new field AREA that will contain the area of each building square meters.

  3. Click OK. The AREA field has been added at the end of the attribute table.

  4. 編集を終了し、プロンプトが表示されたら、編集内容を保存するには、再度編集モードボタンをクリックします。

  5. Build a query as earlier in this lesson

    ../../../_images/buildings_area_query.png
  6. OK をクリックします。

Your map should now only show you those buildings which match our starting criteria and which are more than 100m squared in size.

7.2.12. basic Try Yourself

Save your solution as a new layer, using the approach you learned above for doing so. The file should be saved within the same GeoPackage database, with the name solution.

7.2.13. In Conclusion

QGISベクター分析ツールと一緒にGISの問題解決のアプローチを使用することで、複数の条件での問題を迅速かつ容易に解決できました。

7.2.14. What's Next?

次のレッスンでは、ある地点から別の地点への道に沿って最短距離を計算する方法を見ていきます。