官术网_书友最值得收藏!

  • QGIS By Example
  • Alexander Bruy Daria Svidzinska
  • 417字
  • 2021-07-16 14:09:15

Loading layers from the spatial database

Throughout this chapter, we will use the database that we created earlier. As you remember, this is a SpatiaLite file database. In order to work with it, we must first establish a connection and then load the data. As always, there are a few alternative ways of doing this in QGIS:

  • From the menu, go to Layer | Add Layer | Add SpatiaLite Layer
  • Click on Loading layers from the spatial database, the Add SpatiaLite Layer button, in the Manage Layers toolbar
  • Use the Ctrl + Shift + L keyboard shortcut

In the opened window, define the database you want to connect to by following these steps:

  1. If you have created the database as was described in the previous chapter, you are likely to notice that it has already been connected. If it is not, then click on the New button and navigate to the .sqlite file you want to work with.
  2. After the database file is selected, click on the Connect button to see the list of available layers. You will see the layers' names and geometry types.
  3. Select the necessary layer (or layers, which is done by holding down the Ctrl key) and click on the Add button.
    Note

    The Set filter button gives you more flexibility when adding the data, as it provides access to the Query Builder window, where you can make up a conditional expression to define the sub-dataset, as shown in the following figure. For example, if you want to select a multipurpose play area (MPPA) from the athletic facilities dataset, you can do the following:

    • On the left side of the Query Builder window, select a necessary field called primary_sp (double-click on its name to add to the expression in the Provider specific filter expression textbox)
    • Type in or click on the operator button (the equality sign in our case)
    • Load the field values by clicking on the All button, and double-click on an MPPA value to add it to the expression
    • In the Provider specific filter expression textbox, you will see the following line: "primary_sp" = 'MPPA'

    Test the query. If it returns a meaningful result, click on OK. After returning to the main window, you will see the condition beside the geom column. Click on the Add button to load the layers.

Loading layers is even simpler from the Browser panel. To see the available layers, successively expand SpatiaLite and the relevant database item. Now you can just drag and drop the layers onto the map canvas.

主站蜘蛛池模板: 郸城县| 荔波县| 阜城县| 增城市| 乌苏市| 西乡县| 扶绥县| 关岭| 云龙县| 沾益县| 思南县| 耒阳市| 洛浦县| 都安| 苏尼特右旗| 绥宁县| 邯郸市| 乐都县| 天峻县| 深圳市| 手游| 怀仁县| 安福县| 江都市| 喜德县| 安徽省| 双柏县| 牟定县| 安义县| 莎车县| 青川县| 中超| 大名县| 长治市| 乌审旗| 城口县| 洛川县| 石嘴山市| 壶关县| 阜新| 彰化县|