중요

번역은 여러분이 참여할 수 있는 커뮤니티 활동입니다. 이 페이지는 현재 41.67% 에서 번역되고 있습니다.

18.3. Lesson: Working with SpatiaLite databases in QGIS

While PostGIS is generally used on a server to provide spatial database capabilities to multiple users at the same time, QGIS also supports the use of a file format called SpatiaLite that is a lightweight, portable way to store an entire spatial database in a single file. Obviously, these 2 types of spatial databases should be used for different purposes, but the same basic principles and techniques apply to both. Let’s create a new SpatiaLite database and explore the functionality provided to work with these databases in QGIS.

The goal for this lesson: To learn how to interact with SpatiaLite databases using the QGIS Browser interface.

18.3.1. basic Follow Along: Creating a SpatiaLite database with the Browser

Using the Browser panel, we can create a new SpatiaLite database and get it setup for use in QGIS.

  1. Right click on the SpatiaLite entry in the Browser tree and select Create Database.

  2. Specify where on your filesystem you want to store the file and name it qgis-sl.db.

  3. Again right click on the SpatiaLite entry in the Browser tree and now select the New Connection item. Find the file you created in the last step and open it.

이제 새 데이터베이스를 생성했지만, 브라우저 트리에 있는 해당 항목 아래 아무것도 없으며 이 시점에서 사용자가 할 수 있는 일이라곤 연결을 삭제하는 것뿐이라는 사실을 알게 될 것입니다. 물론 이 데이터베이스에 아무 테이블도 추가하지 않았기 때문입니다. 테이블을 추가해보겠습니다.

  1. Find the button to create a new layer and use the dropdown to create a new SpatiaLite layer, or select Layer ► New ► newSpatiaLiteLayer New SpatiaLite Layer.

  2. 드롭다운 메뉴에서 이전 단계에서 생성했던 데이터베이스를 선택하십시오.

  3. Give the layer the name places.

  4. Create an auto-incrementing primary key 항목의 체크박스를 체크하십시오.

  5. Add two attributes as shown in below

  6. :guilabel:`OK`를 클릭해서 테이블을 생성하십시오.

    ../../../_images/new_layer_setup.png
  7. Click the refresh button at the top of the Browser and you should now see your places table listed.

    ../../../_images/new_layer_added.png

    해당 테이블을 오른쪽 클릭하면, 이전 예제들에서와 마찬가지로 테이블의 속성을 살펴볼 수 있습니다.

이제 편집 세션을 시작해서 사용자의 새 데이터베이스에 직접 데이터를 추가할 수 있습니다.

We also learned about how to import data into a database using the DB Manager and you can use this same technique to import data into your new SpatiaLite DB.

18.3.2. In Conclusion

You have seen how to create SpatiaLite databases, add tables to them and use these tables as layers in QGIS.