QGIS 3.0 在线免费视频教程

最近发现好多朋友来博客的目的是寻找qgis相关的内容,早些年打算翻译的qgis训练手册也烂尾了,所以这段时间集中精力录制了几段qgis的视频教程,供大家参考。 虽然之前也录制过几段视频,但录制经验不足,有些地方读错发音,有的地方流畅度有待提升……唉,还望大家见谅哈。 不过,这个应该也算得上是国内少有的qgis视频教程了,还请大家多捧捧场。 继续阅读“QGIS 3.0 在线免费视频教程”

【译】QGIS培训手册-标签工具(1)

4.2. Lesson: 标签工具The Label Tool

标签可以被添加到地图来显示关于某对象的任何信息。任何矢量图层可以有与之关联的标签。这些标签是依靠其属性数据的内容创建的。Labels can be added to a map to show any information about an object. Any vector layer can have labels associated with it. These labels rely on the attribute data of a layer for their content.

Note

图层属性对话框里面有个标签选项,也有本节课所讲的功能,但是本节主要以工具栏上的标签工具来解说。The Layer Properties dialog does have a Labels tab, which now offers the same functionality, but for this example we’ll use the Label tool, accessed via a toolbar button.

本节目标:为某个图层添加有用好看的标签。The goal for this lesson: To apply useful and good-looking labels to a layer.

4.2.1. basic 跟我做:使用标签Follow Along: Using Labels

在使用标签工具之前,请先确定该工具已被激活。Before being able to access the Label tool, you will need to ensure that it has been activated.

  • 执行: 视图 ‣ 工具栏.Go to the menu item View ‣ Toolbars.
  • 确保标签 选项已被选中,若没被选中,那就现在选中它。Ensure that the Label item has a check mark next to it. If it doesn’t, click on the Label item, and it will be activated.
  • 在图层列表中点击places 图层,你会看到该层会被高亮显示。Click on the places layer in the Layers list, so that it is highlighted.
  • 点击工具栏上的这个按钮mActionLabeling。Click on the following toolbar button: mActionLabeling

这会打开 图层标签设置 对话框。This gives you the Layer labeling settings dialog.

  • 选中 给该图层加上标签,标签字段为…….Check the box next to Label this layer with….

这时候,你需要选择一个用于绘制标签的字段。根据之前的课程对本数据的了解,我们选择最适合做标签的 NAME 字段。You’ll need to choose which field in the attributes will be used for the labels. In the previous lesson, you decided that the NAME field was the most suitable one for this purpose.

  • 从列表中选择 name 字段。Select name from the list:

../../../_images/select_label_with.png

  • 点击 确定 。 Click OK.

现在,地图将添加上标签了,如下图。The map should now have labels like this:

../../../_images/first_place_names.png

4.2.2. basic 跟我做:更改标签选项Follow Along: Changing Label Options

基于之前课程你所设置的地图样式,你可能会发现标签的格式不太合适,或者他们距离其标注点太远/太近等等。Depending on the styles you chose for your map in earlier lessons, you’ll might find that the labels are not appropriately formatted and either overlap or are too far away from their point markers.

  • 点击工具栏上的按钮,再次打开 标签  工具。Open the Label tool again by clicking on its button as before.
  • 确保对话框左下方列表中的 文本  被选中。然后,你可以在其右侧的选项中更改其文本样式。Make sure Text is selected in the left-hand options list, then update the text formatting options to match those shown here:

../../../_images/label_formatting_options.png这样就可以解决字体不合适等问题了。接下来要解决标签与标注点重合的问题。开始之前,我们先看一下 使用轮廓缓冲区  选项。That’s the font problem solved! Now let’s look at the problem of the labels overlapping the points, but before we do that, let’s take a look at the Buffer option.

  • 还是打开标签工具对话框。Open the Label tool dialog.
  • 从左下框里面选使用轮廓缓冲区 。Select Buffer from the left-hand options list.
  • 勾选 绘制文本缓冲区 ,然后按照下图设置。Select the checkbox next to Draw text buffer, then choose options to match those shown here:

../../../_images/buffer_options.png

  • 点击应用。Click Apply.

这时你会看到我们给标签添加了一个彩色的缓冲区(或边框),让标签从地图上看起来更清楚。You’ll see that this adds a colored buffer or border to the place labels, making them easier to pick out on the map:

../../../_images/buffer_results.png现在我们来设置标签与标记点之间的位置。Now we can address the positioning of the labels in relation to their point markers.

  • 图层标签  对话框中,左下框中选中位置  。In the Label tool dialog, go to the Placement tab.
  • 选中 点周围 ,并将 距离 设置为2mm 。Change the value of Distance to 2mm and make sure that Around point is selected:

../../../_images/offset_placement_settings.png

  • 点击应用。Click Apply.

这时候你会看到标签将不会重叠在它们的标记点上了。You’ll see that the labels are no longer overlapping their point markers.

4.2.3. moderate 跟我做:用标签代替图层符号Follow Along: Using Labels Instead of Layer Symbology

在许多情况下,点的位置并不需要非常具体。例如, places 层中大多数点是代表了整个城镇或郊区,并与这些与要素关联的特定点在大比例尺下并不是很具体。事实上,给出一堆很具体的点往往会把阅读地图的人弄得更糊涂。In many cases, the location of a point doesn’t need to be very specific. For example, most of the points in the places layer refer to entire towns or suburbs, and the specific point associated with such features is not that specific on a large scale. In fact, giving a point that is too specific is often confusing for someone reading a map.

举一个例子: 在世界地图上,欧盟的点可能标注在波兰的某个地方,但阅读地图的人看到这个点在波兰后,他会认为欧盟的总部在波兰(【译者注】实际上在比利时首都布鲁塞尔)。To name an example: on a map of the world, the point given for the European Union may be somewhere in Poland, for instance. To someone reading the map, seeing a point labeledEuropean Union in Poland, it may seem that the capital of the European Union is therefore in Poland.

因此,为了防止这种误解,我们会停用点符号并将它们完全用标签来替代。So, to prevent this kind of misunderstanding, it’s often useful to deactivate the point symbols and replace them completely with labels.

在 QGIS,你可以通过改变标签位置,直接在它们引用点的位置来呈现。In QGIS, you can do this by changing the position of the labels to be rendered directly over the points they refer to.

  • 打开 places 图层的图层标签设置  对话框。Open the Layer labeling settings dialog for the places layer.
  • 选择 位置 选项。Select the Placement option from the options list.
  • 选中离点便宜量  单选按钮。Click on the Offset from point button.

这将显示象限选项,您可以使用象限选项设置标签与点标记的位置关系。在本例中,我们想要以点为中心,所以选择中心象限标签:This will reveal the Quadrant options which you can use to set the position of the label in relation to the point marker. In this case, we want the label to be centered on the point, so choose the center quadrant:

../../../_images/quadrant_offset_options.png

  • 通过编辑图层样式的方式来不显示点样式,具体为:将椭圆标记的宽度和高度的大小设置为 0,如下图。Hide the point symbols by editing the layer style as usual, and setting the size of the Ellipse marker width and height to 0:

../../../_images/hide_point_marker.png

  • 点击确定来查看结果。Click OK and you’ll see this result:

../../../_images/hide_point_marker_results.png如果你是要缩小地图,你会看到一些标签会消失以避免在缩小的地图上重叠。有时这是你想要的效果,特别是处理有很多点的数据集时;但在其他时候,这种方式将失去一些有用的信息。除这两种外,还有另一种可能性,我们将在以后的练习中了解学习。If you were to zoom out on the map, you would see that some of the labels disappear at larger scales to avoid overlapping. Sometimes this is what you want when dealing with datasets that have many points, but at other times you will lose useful information this way. There is another possibility for handling cases like this, which we’ll cover in a later exercise in this lesson.

4.2.4. moderate 动手试:自定义标签Try Yourself Customize the Labels

  • 返回到之前对标签和样式的设置,让点标记和标签偏移量为 2.00 毫米。在本阶段,你可以随意调整的点标记和标签的样式。Return the label and symbol settings to have a point marker and a label offset of 2.00mm. You may like to adjust the styling of the point marker or labels at this stage.

Check your results

  • 将比例尺设置为1:100000。可以在状态栏比例尺框中直接输入。Set the map to the scale 1:100000. You can do this by typing it into the Scale box in theStatus Bar.
  • 将标签调整到此比例尺下合适的样式。Modify your labels to be suitable for viewing at this scale.

Check your results

【译】QGIS培训教程-4.1属性数据

4. Module: 对矢量数据进行分类(Classifying Vector Data)

4.1. Lesson: 属性数据(Attribute Data)

到目前为止,我们对地图所做的更改并没有影响展示的要素。换句话说,所有的土地使用地区都是一样的,并且,所有的道路看起来也一样。当我们在看图时,读图者不会从图上独到任何道路的信息,他们只能看到某区域一条特定形状的路而已。(Up to now, none of the changes we have made to the map have been influenced by the objects that are being shown. In other words, all the land use areas look alike, and all the roads look alike. When looking at the map, the viewers don’t know anything about the roads they are seeing; only that there is a road of a certain shape in a certain area.)

但GIS的整体优势是地图上所有可见的对象都具有属性。GIS 中的地图并不只是图片。它不仅能描述物体的位置,而且带有这些对象的信息。(But the whole strength of GIS is that all the objects that are visible on the map also have attributes. Maps in a GIS aren’t just pictures. They represent not only objects in locations, but also information about those objects.)

本课目的:(The goal of this lesson: 探索对象的属性数据,并了解这些数据的用途。(To explore the attribute data of an object and understand what the various data can be useful for.)

4.1.1.  跟我做:属性数据Follow Along: Attribute data

打开的 places图层的属性表 (如有必要,请参阅”操作矢量数据”一节)。看一看,哪些字段信息最适合用来做标签呢,为什么?(Open the attribute table for the places layer (refer back to the section “Working with Vector Data” if necessary). Which field would be the most useful to represent in label form, and why?)

Check your results

4.1.2. 小结In Conclusion

你现在已经知道如何查看你所使用的数据的属性表了。只有带有我们关心的信息的数据集才是有用的。如果你知道你需要哪些属性,你可以快速判断某个给定的数据集是否有用,否则我们需要寻找另一个具有必需的属性数据的数据集。(You now know how to use the attribute table to see what is actually in the data you’re using. Any dataset will only be useful to you if it has the attributes that you care about. If you know which attributes you need, you can quickly decide if you’re able to use a given dataset, or if you need to look for another one that has the required attribute data.)

4.1.3. 下节提要What’s Next?

不同的属性可用于不同的目的。其中一些可以直接作为读图标签。下节课我们将重点学这个内容。(Different attributes are useful for different purposes. Some of them can be represented directly as text for the map user to see. You’ll learn how to do this in the next lesson.)

【译】QGIS培训手册-样式(4)

3.2.12. hard 跟我做:创建一个自定义的SVG填充(FOLLOW ALONG: CREATING A CUSTOM SVG FILL)

Note

注意,你需要首先安装一个免费的矢量编辑软件Inkscape,才能继续下面的练习。【译者注:如果你有illustrator、CorelDRAW等矢量软件,也可的。我到网上找了两个Inkscape的安装包,都打不开,装不上,所以没有试验过。】(To do this exercise, you will need to have the free vector editing software Inkscape installed.)

  • 启动Inkscape程序。(Start the Inkscape program.)

你会看到以下界面:(You will see the following interface:)

../../../_images/inkscape_default.png

你会看到它跟其他的一些矢量软件,比如Corel等类似。(You should find this familiar if you have used other vector image editing programs, like Corel.)

首先,我们把画布调整为适合小符号纹理的尺寸。(First, we’ll change the canvas to a size appropriate for a small texture.)

  • 点击菜单中的文件>文档属性。然后会填出文档属性对话框。(Click on the menu item File Document Properties. This will give you the Document Properties dialog.)
  • 将单位设置为像素(px。(Change the Units to px.
  • 将宽度和高度设置为 100。(Change the Width and Height to 100.)
  • 设置完后就关闭该对话框。(Close the dialog when you are done.)
  • 点击菜单上的视图>缩放>页面,来将视窗缩放到我们刚刚设置的页面上。(Click on the menu item View Zoom Page to see the page you are working with.)
  • 选择椭圆工具。(Select the Circle tool:)

../../../_images/inkscape_circle_tool.png

  • 按下ctrl  键,拖动椭圆工具来绘制一个正圆。(Click and drag on the page to draw an ellipse. To make the ellipse turn into a circle, hold thectrl button while you’re drawing it.)
  • 在所绘制的圆形上右键,打开填充画笔选项。(Right-click on the circle you just created and open its Fill and Stroke:)
  • 将填充和描边样式设置为下图所示:(Change the Stroke paint to a pale grey-blue and the Stroke style to a darker color with thin stroke:)

../../../_images/inkscape_stroke_fill.png

  • 用直线工具来绘制一条线:(Draw a line using the Line tool:)
  • 先点一下表示开始绘制直线,按下ctrl 键来保证直线偏移能以15度角的倍数变化。【译者注:目的是为了绘制出横平竖直的线条】(Click once to start the line. Hold ctrl to make it snap to increments of 15 degrees.)
  • 再点一下就绘制了一个线段,然后右键来完成直线的绘制。(Click once to end the line segment, then right-click to finalize the line.)
  • 改变直线的颜色和宽度,使之与之前的园的样式匹配,并对其进行适当移动,使之看起来这样:(Change its color and width to match the circle’s stroke and move it around as necessary, so that you end up with a symbol like this one:)

../../../_images/inkscape_final_symbol.png

  • 将其保存在exercise_data/symbols目录下,新建一个landuse_symbol  的文件夹,并保存为SVG格式。(Save it as landuse_symbol under the directory that the course is in, underexercise_data/symbols, as an SVG file.)

回到QGIS:(In QGIS:)

  • 打开landuse 图层的图层属性。(Open the Layer Properties for the landuse layer.)
  • 按照下图所示,通过浏览按钮来加载刚刚制作的svg图像,来改变图层的符号样式。(Change the symbol structure to the following and find your SVG image via the Browsebutton:)

../../../_images/svg_symbol_settings.png

并按下面改变svg图层的边框:(You may also wish to update the svg layer’s border:)

../../../_images/svg_layer_border.pnglanduse图层,现在会看起来是这个样了:(Your landuse layer should now have a texture like the one on this map:)

../../../_images/svg_symbol_result.png

3.2.13. 总结(IN CONCLUSION)

通过改变不同图层的符号样式可以将原来的矢量文件集合转变为一副清晰的地图。不但能看懂地图的内容,而且地图样式也很好看!(Changing the symbology for the different layers has transformed a collection of vector files into a legible map. Not only can you see what’s happening, it’s even nice to look at!)

3.2.14. 进阶阅读(FURTHER READING)

Examples of Beautiful Maps(这是一个国外的论坛链接,里面有好多漂亮的地图制作分享)

3.2.15. 下节提要(WHAT’S NEXT?)

通过更改整个图层的符号是有用的,但对读图者来说,每一层内包含的信息仍不可用。街道是叫什么名字?这个地方是属于哪个行政区域?农场的占地面积是多大?所有这些信息仍然是隐藏的。下一课中将解释如何将数据标示在你的地图上。(Changing symbols for whole layers is useful, but the information contained within each layer is not yet available to someone reading these maps. What are the streets called? Which administrative regions do certain areas belong to? What are the relative surface areas of the farms? All of this information is still hidden. The next lesson will explain how to represent this data on your map.)

Note

本节课中你养成经常保存的习惯了吗?Did you remember to save your map recently?