2.2. Lesson: Adding your first layers

アプリケーションを起動し、その例と演習で使用する基本的な地図を作成します。

このレッスンの目標: 例の地図で始める

注釈

Before starting this exercise, QGIS must be installed on your computer. Also, you should have downloaded the sample data to use.

デスクトップのショートカット、メニュー、アイテムなどからQGISを起動します。この設定はインストール時の設定に依存します。

注釈

The screenshots for this course were taken in QGIS 3.4 running on Linux. Depending on your setup, the screens you encounter may well appear somewhat different. However, all the same buttons will still be available, and the instructions will work on any OS. You will need QGIS 3.4 (the latest version at time of writing) to use this course.

すぐにはじめましょう!

2.2.1. basic Follow Along: 地図を準備

  1. QGISを開きます。新規に空白の地図があります。

    ../../../_images/add_blank_qgis.png
  2. The Data Source Manager dialog allows you to choose the data to load depending on the data type. We'll use it to load our dataset: click the dataSourceManager Open Data Source Manager button.

    If you can't find the icon, check that the Data Source Manager toolbar is enabled in the View ► Toolbars menu.

    ../../../_images/add_data_dialog.png
  3. Load the protected_areas.shp vector dataset:

    1. Click on the Vector tab.

    2. Enable the radioButtonOnFile source type.

    3. Press the ... button next to Vector Dataset(s).

    4. Select the exercise_data/shapefile/protected_areas.shp file in your training directory.

    5. Click Open. You will see the original dialog, with the file path filled in.

      ../../../_images/add_vector_dialog.png
    6. Click Add here as well. The data you specified will now load: you can see a protected_areas item in the Layers panel (bottom left) with its features shown in the main map canvas.

      ../../../_images/first_loaded_layer.png

おめでとうございます!これで基本的な地図ができました。作業を保存するにはよいタイミングでしょう。

  1. 名前を付けて保存 ボタンをクリックしてください: fileSaveAs

  2. Save the map under a solution folder next to exercise_data and call it basic_map.qgz.

2.2.2. basic Try Yourself

Repeat the steps above to add the places.shp and rivers.shp layers from the same folder (exercise_data/shapefile) to the map.

結果の確認

2.2.3. basic Follow Along: Loading vector data from a GeoPackage Database

Databases allow you to store a large volume of associated data in one file. You may already be familiar with a database management system (DBMS) such as Libreoffice Base or MS Access. GIS applications can also make use of databases. GIS-specific DBMSes (such as PostGIS) have extra functions, because they need to handle spatial data.

The GeoPackage open format is a container that allows you to store GIS data (layers) in a single file. Unlike the ESRI Shapefile format (e.g. the protected_areas.shp dataset you loaded earlier), a single GeoPackage file can contain various data (both vector and raster data) in different coordinate reference systems, as well as tables without spatial information; all these features allow you to share data easily and avoid file duplication.

In order to load a layer from a GeoPackage, you will first need to create the connection to it:

  1. Click on the dataSourceManager Open Data Source Manager button.

  2. On the left click on the newGeoPackageLayer GeoPackage tab.

  3. Click on the New button and browse to the training_data.gpkg file in the exercise_data folder you downloaded before.

  4. Select the file and press Open. The file path is now added to the Geopackage connections list, and appears in the drop-down menu.

You are now ready to add any layer from this GeoPackage to QGIS.

  1. Click on the Connect button. In the central part of the window you should now see the list of all the layers contained in the GeoPackage file.

  2. Select the roads layer and click on the Add button.

    ../../../_images/add_data_dialog_geopackage.png

    A roads layer is added to the Layers panel with features displayed on the map canvas.

  3. Click on Close.

Congratulations! You have loaded the first layer from a GeoPackage.

2.2.4. basic Follow Along: Loading vector data from a SpatiaLite Database with the Browser

QGIS provides access to many other database formats. Like GeoPackage, the SpatiaLite database format is an extension of the SQLite library. And adding a layer from a SpatiaLite provider follows the same rules as described above: Create the connection --> Enable it --> Add the layer(s).

While this is one way to add SpatiaLite data to your map, let's explore another powerful way to add data: the Browser.

  1. Click the dataSourceManager icon to open the Data Source Manager window.

  2. Click on the fileOpen Browser tab.

  3. In this tab you can see all the storage disks connected to your computer as well as entries for most of the tabs in the left. These allow quick access to connected databases or folders.

    For example, click on the drop-down icon next to the geoPackage GeoPackage entry. You'll see the training-data.gpkg file we previously connected to (and its layers, if expanded).

  4. Right-click the spatialite SpatiaLite entry and select New Connection....

  5. Navigate to the exercise_data folder, select the landuse.sqlite file and click Open.

    Notice that a dbSchema landuse.sqlite entry has been added under the SpatiaLite one.

  6. Expand the dbSchema landuse.sqlite entry.

  7. Double-click the polygonLayer landuse layer or select and drag-and-drop it onto the map canvas. A new layer is added to the Layers panel and its features are displayed on the map canvas.

    ../../../_images/spatialite_dialog_connected.png

ちなみに

Enable the Browser panel in View ► Panels ► and use it to add your data. It's a handy shortcut for the Data Source Manager ► Browser tab, with the same functionality.

注釈

Remember to save your project frequently! The project file doesn't contain any of the data itself, but it remembers which layers you loaded into your map.

2.2.5. moderate Try Yourself Load More Vector Data

Load the following datasets from the exercise_data folder into your map using any of the methods explained above:

  • buildings

  • water

Check your results

2.2.6. Follow Along: レイヤーの順序入れ替え

レイヤーリストにあるレイヤーは、特定の順序で地図上に描かれます。リストの一番下にあるレイヤーが最初に描かれ、そして一番上のレイヤーは最後に描かれます。リストに表示される順を変更することで、それらが描かれる順序を変更できます。

注釈

You can alter this behavior using the Control rendering order checkbox beneath the Layer Order panel. We will however not discuss this feature yet.

レイヤーが地図にロードされた順序は、おそらくこの段階では論理的ではありません。他のレイヤーがその上にあることで道路レイヤーが完全に隠れている可能性があります。

たとえば、このレイヤー順では・・・

../../../_images/incorrect_layer_order.png

... would result in roads and places being hidden as they run underneath the polygons of the landuse layer.

問題を解決するために:

  1. レイヤーリスト中でレイヤーをクリックしてドラッグします。

  2. こう見えるようにそれらの順番を入れ替えます:

../../../_images/correct_layer_order.png

地図は現在、土地利用領域の上に表示される道路や建物で、視覚的により理にかなっていることがわかります。

2.2.7. In Conclusion

Now you've added all the layers you need from several different sources and created a basic map!

2.2.8. What's Next?

Now you're familiar with the basic function of the Open Data Source Manager button, but what about all the others? How does this interface work? Before we go on, let's take a look at some basic interaction with the QGIS interface. This is the topic of the next lesson.