3.1. 操作矢量数据(Lesson: Working with Vector Data)

矢量数据无疑是GIS日常操作中最常见的一种数据。它以点、线和多边形的形式来描绘地理数据。矢量数据集中的每个对象被称为形状(feature),并有相对应的数据与之关联。(Vector data is arguably the most common kind of data you will find in the daily use of GIS. It describes geographic data in terms of points, that may be connected into lines and polygons. Every object in a vector dataset is called a feature, and is associated with data that describes that feature.)

本节课的目的:学习矢量数据的结构,并掌握如何加载他们到地图中。(The goal for this lesson: To learn about the structure of vector data, and how to load vector datasets into a map.)

3.1.1. basic 跟我做:查看图层属性(Follow Along: Viewing Layer Attributes)

首先要明确的是,我们即将操作的数据,不仅代表了他们在空间中的位置,还包含了他们是什么的各种属性(It’s important to know that the data you will be working with does not only represent where objects are in space, but also tells you what those objects are.)

接前面的练习,在你的地图中已经加载了道路层。你也可以看到现在只是展示了道路的位置。(From the previous exercise, you should have the roads layer loaded in your map. What you can see right now is merely the position of the roads.)

要看到所有的形状要素属性,先在图层列表面板中选中该图层。(To see all the data available to you, with the roads layer selected in the Layers panel:)

  • 点击这个按钮:attributes(Click on this button: attributes

你会看到一个关于道路图层有更多信息的数据表。这些额外的数据被称为属性数据。在地图中能看到的那些线条是空间数据。(It will show you a table with more data about the roads layer. This extra data is called attribute data. The lines that you can see on your map represent where the roads go; this is the spatial data.)

这是GIS中很常见的一些定义,比较重要,请记住它们。(These definitions are commonly used in GIS, so it’s essential to remember them!)

  • (现在,可以关闭属性表了)You may now close the attribute table.

矢量数据在坐标平面上以点、 线和多边形的形式来表现图形要素。它通常用于存储离散的图形要素,如道路和城市街区等。(Vector data represents features in terms of points, lines and polygons on a coordinate plane. It is usually used to store discrete features, like roads and city blocks.)

3.1.2. basic 跟我做:从shp加载矢量数据(Follow Along: Loading Vector Data From Shapefiles)

Shapefile 是一种可以将 GIS 数据存储在一组关联的多个文件中的特定文件格式【译者注:每个shp文件都是由多个文件组成的】。这些文件有共同的文件名,但是有各自的不同的扩展名(文件类型)。Shapefiles 可以很方便的来回发送,并且大多数 GIS 软件都可以阅读它们。(The Shapefile is a specific file format that allows you to store GIS data in an associated group of files. Each layer consists of several files with the same name, but different file types. Shapefiles are easy to send back and forth, and most GIS software can read them.)

参考上一节所讲的如何加载矢量图层的方法,(Refer back to the introductory exercise in the previous section for instructions on how to add vector layers.)

把以下数据集加载到地图中:(Load the data sets into your map following the same method:)

  • “places”
  • “water”
  • “rivers”
  • “buildings”


3.1.3. basic 跟我做:从数据库中加载矢量数据(Follow Along: Loading Vector Data From a Database)

数据库能够让你在一个文件中存储了大量的相关联的数据。您可能已经对类似 Microsoft Access这样的 数据库管理系统 (DBMS)有所了解。GIS应用程序也可以使用的数据库。具有地理信息系统特性的 DBMS (比如 PostGIS) 会有额外的功能,因为他们需要处理空间数据。(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 Microsoft 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.)

  • 点击这个按钮:mActionAddSpatiaLiteLayer(Click on this icon: mActionAddSpatiaLiteLayer

(如果你找不到该按钮,检查 图层管理 工具栏是否被打开)(If you’re sure you can’t see it at all, check that the Manage Layers toolbar is enabled.)

将打开一个新的对话框。在这个对话框中:(It will give you a new dialog. In this dialog:)

  • 点击新建 按钮。(Click the New button.)
  • 在之前的路径下,找到landuse.sqlite这个文件。选中它,并打开。(In the same folder as the other data, you should find the file landuse.sqlite. Select it and click Open.)

你会看到在刚刚的那个对话框里面,三个按钮的上面已经填写上了 “land_use.db@…”这样的文字,@后面跟着的是你计算机上数据库文件的路径。You will now see the first dialog again. Notice that the dropdown select above the three buttons now reads “land_use.db@…”, followed by the path of the database file on your computer.

  • 点击 连接 按钮。你会发现在原来的空白区域多出了一条内容:(.Click the Connect button. You should see this in the previously empty box:)


  • 点击 landuse 图层来选中它,然后点击 添加按钮。(Click on the landuse layer to select it, then click Add)


记得要养成经常保存地图的习惯!地图文件不会直接包含任何数据,但是它会记住那些已被加载的图层。(Remember to save the map often! The map file doesn’t contain any of the data directly, but it remembers which layers you loaded into your map.)

3.1.4. 跟我做:给图层排序(Follow Along: Reordering the Layers)

在图层列表中的图层会按照一定的顺序进行绘制。在列表顶部的图层最先绘制,列表底部的图层最后绘制。通过更改它们在列表中排列的顺序,可以更改绘制它们的顺序。(The layers in your Layers list are drawn on the map in a certain order. The layer at the bottom of the list is drawn first, and the layer at the top is drawn last. By changing the order that they are shown on the list, you can change the order they are drawn in.)


根据你所使用的 QGIS 的版本,在图层列表下面可能会有一个叫控制渲染顺序 的复选框。如果想要实现通过上下排序来控制图层先后顺序,必须将这个复选框选中。如果您的版本的 QGIS 没有此选项,它就是默认开启的,你不需要担心这件事【译者注:在最新的QGIS版本中,已经没有了这个复选框】。(Depending on the version of QGIS that you are using, you may have a checkbox beneath your Layers list reading Control rendering order. This must be checked (switched on) so that moving the layers up and down in the Layers list will bring them to the front or send them to the back in the map. If your version of QGIS doesn’t have this option, then it is switched on by default and you don’t need to worry about it.)

当前已经加载的图层可能绘制的顺序是不合逻辑的。比如道路可能是完全被挡住的,因为有别的图层在它上面。The order in which the layers have been loaded into the map is probably not logical at this stage. It’s possible that the road layer is completely hidden because other layers are on top of it.

比如说这种图层顺序(landuse就会把road挡住):(For example, this layer order..).


通过以下措施来解决这个问题:(To resolve this problem:)

  • 按住并拖拽某个图层(来调整顺序)(Click and drag on a layer in the Layers list.)
  • 将各个图层按以下顺序排序:(Reorder them to look like this:)

../../../_images/correct_layer_order.png现在地图变得更有意义了,道路和建筑物出现在土地使用区域的上面。(You’ll see that the map now makes more sense visually, with roads and buildings appearing above the land use regions.)

3.1.5.小结( In Conclusion)

现在你已经学会了添加不同来源的矢量图层。(Now you’ve added all the layers you need from several different sources.)

3.1.6. What’s Next?

使用加载图层时随机生成的样式和颜色可能会导致你的地图不太好识别。所以我们要自己来设定他们的颜色和符号,这就是下一节课的内容。(Using the random palette automatically assigned when loading the layers, your current map is probably not easy to read. It would be preferable to assign your own choice of colors and symbols. This is what you’ll learn to do in the next lesson.)



邮箱地址不会被公开。 必填项已用*标注

填写验证码: *