3.1. Lesson: 벡터 데이터 작업

Vector data is arguably the most common kind of data you will find in the daily use of GIS. The vector model represents the location and shape of geographic features using points, lines and polygons (and for 3D data also surfaces and volumes), while their other properties are included as attributes (often presented as a table in QGIS). It is usually used to store discrete features, like roads and city blocks. The objects in a vector dataset are called features, and contain data that describe their location and properties.

이 강의의 목표: 벡터 데이터의 구조와 맵에 벡터 데이터셋을 로드하는 방법을 배우기.

3.1.1. basic Follow Along: 레이어 속성 뷰

여러분이 작업할 데이터가 오브젝트가 어디에 위치하는지 나타낼 뿐만 아니라 어떤 오브젝트인지도 나타낸다는 사실을 알아야 합니다.

From the previous exercise, you should have the protected_areas layer loaded in your map. If it is not loaded, then you can find the protected_areas.shp ESRI Shapefile format dataset in directory exercise_data/shapefile.

The polygons representing the protected areas constitute the spatial data, but we can learn more about the protected areas by exploring the attribute table.

  1. In the Layers panel, click on the protected_areas layer to select it.

  2. In the Attributes Toolbar click the openTable Open Attribute Table button. This will open a new window showing the attribute table of the protected_areas layer.

    ../../../_images/attribute_data_preview.png

    A row is called a record and is associated with a feature in the Canvas Map, such as a polygon. A column is called a field (or an attribute), and has a name that helps describe it, such as name or id. Values in the cells are known as attribute values. These definitions are commonly used in GIS, so it is good to become familiar with them.

    In the protected_areas layer, there are two features, which are represented by the two polygons we see on the Map Canvas.

    참고

    In order to understand what the fields and attribute values represent, one may need to find documentation (or metadata) describing the meaning of the attribute values. This is usually available from the creator of the data set.

Next, let’s see how a record in the attribute table is linked to a polygon feature that we see on the Map Canvas.

  1. Go back to the main QGIS window.

  2. In the Attributes Toolbar, click on the selectFeature Select Feature button.

  3. Make sure the protected_areas layer is still selected in the Layers panel.

  4. Move your mouse to the Map Canvas and left click on the smaller of the two polygons. The polygon will turn yellow indicating it is selected.

    ../../../_images/select_polygon.png
  5. Go back to the Attribute Table window, and you should see a record (row) highlighted. These are the attribute values of the selected polygon.

    ../../../_images/select_record.png

You can also select a feature using the Attribute Table.

  1. In the Attribute Table window, on the far left, click on the row number of the record that is currently not selected.

    ../../../_images/select_record2.png
  2. Go back to the main QGIS window and look at the Map Canvas. You should see the larger of the two polygons colored yellow.

  3. To deselect the feature, go to the Attribute Table window and click on deselectAll Deselect All button.

Sometimes there are many features shown on the Map Canvas and it might be difficult to see which feature is selected from the Attribute Table. Another way to identify the location of a feature is to use the Flash Feature tool.

  1. In the Attribute Table, right-click on any cell in the row that has the attribute value r2855697 for the field full_id.

  2. In the context menu, click on Flash Feature and watch the Map Canvas.

    ../../../_images/flash_feature.png

    You should see the polygon flash red a few times. If you missed it, try it again.

Another useful tool is the Zoom to Feature tool, that tells QGIS to zoom to the feature of interest.

  1. In the Attribute Table, right-click on any cell in the row that has the attribute value r2855697 for the field full_id.

  2. In the context menu, click on Zoom to Feature

    ../../../_images/zoom_to_feature.png

    Look at the Map Canvas. The polygon should now occupy the extent of the Map Canvas area.

이제 속성 테이블을 닫으십시오.

3.1.2. basic Try Yourself Exploring Vector Data Attributes

  1. How many fields are available in the rivers layer?

  2. Tell us a bit about the town places in your dataset.

Check your results

3.1.3. basic Follow Along: Loading Vector Data From 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.

3.1.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.

3.1.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

3.1.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.

현재 맵 상에 레이어가 로드되는 순서가 전혀 논리적이지 않을 수도 있습니다. 다른 레이어들이 road 레이어를 덮어 완전히 가려져 있을 수도 있습니다.

예를 들어 레이어 순서를 이렇게 하면…

../../../_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

이제 도로와 건물이 토지이용구역 위에 나타나는, 시각적으로 더 논리적인 맵을 볼 수 있습니다.

3.1.7. In Conclusion

이제 몇 가지 다른 소스들로부터 필요한 모든 레이어를 추가했습니다.

3.1.8. What’s Next?

레이어를 로드할 때 랜덤한 색상이 자동적으로 적용되므로, 현재 사용자 맵을 읽기 힘들 수도 있습니다. 사용자가 직접 색상 및 심볼을 적용하는 편이 좋습니다. 다음 강의에서 그 방법을 배울 것입니다.