In this chapter, we will learn what is meant by vector data. We will practice adding it to our QGIS projects, and we will learn how to style the data in different ways.
Vector data is the most common type of data found in GIS. A vector is essentially something in the form of a dots, or lines connecting those dots. In other words, points, lines, and polygons are all vectors. (curved lines are vectors too, but we won’t worry about that for now) We are already quite familiar with vector data because in the previous unit, we used JOSM to create it!
Each object in a vector dataset is referred to as a feature. When we are using JOSM we often refer to them as objects, but in traditional GIS terminology they are features. A polygon that represents a building is a feature, as is a line that represents a river. Each feature has a geographic location, and is attached to other data that describe the feature.
One important thing to note is that QGIS layers can only contain one type of feature. That is, one layer can’t contain both point features and line features, because they are different types of data. Hence if you have a file that contains school polygons and another file that contains school points, you would add them as two separate layers.
Almost always, polygon layers will be at the bottom of your layer list, line layers in the middle, and point layers at the top. You don’t generally want your polygons overlapping your lines and points.
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.
Before you can add new vector data, you need a vector dataset (a layer to add it to). In our case, we’ll begin by creating a new data layer, and then we will discuss how to edit existing vector layer in QGIS, and how to create an entirely new dataset.
At this point we must decide what kind of dataset we want to create. Remember that a data layer can only contain feature of points, lines, or polygons – never a mix. When we create the layer, we must define what type of data it will contain.
Since polygon are made up of points and lines. Let’s jump into polygons. Once you’ve mastered this, creating a point or a line should be easy!
Shapefile is a commonly used geographic file format. It can easily be converted into other formats, and most GIS software can read this type of file.
Digitising, as you might have guessed, is the art (or science) of creating digital vector data from another source, such as a raster image. In order to begin digitising, we must firt enter edit mode. GIS software commonly requires a separate mode for editing, to prevent user from accidentally editing or deleting important data. Edit mode is switched on or off individually for each layer.
From left to right on the image above, they are:
- Toggle Editing: activates / deactivates edit mode.
- Save Layer Edits: saves changes made to the layer.
- Add Feature: start digitising a new feature.
- Move Feature(s): move an entire feature around.
- Node Tool: move only one part of a feature.
- Delete Selected: delete the selected feature (only active if a feature is selected).
- Cut Features: cut the selected feature (only active if a feature is selected).
- Copy Features: copy the selected feature (only active if a feature is selected).
- Paste Features: paste a cut or copied feature back into the map (only active if a feature has been cut or copied).
It’s important to check Avoid intersection if you want to create a polygon with each feature snap each other.
You’ll notice that your mouse cursor become a crosshair. This allow you to more accurately place the points you’ll be digitising. Remember that even as you’re using the digitising tool, you can zoom in and out on your map by rolling the mouse wheel, and you can pan around by holding down the mouse wheel and dragging around in the map.*
If you make a mistake while digitising a feature, you can always edit it later. Simply finish digitising the feature and then follow these steps:
|Move feature(s) tools||Move entire feature(s)|
|Node tools||Move only one point where you may have misclicked|
|Delete selected||Get rid of the feature entirely so you can try again|
|Undo||Undo mistakes or press Ctrl + Z on keyboard|
Now try it on your own:
When you are finished adding feature to a layer, you must savee the changes to that layer.
Now you know how to create polygon feature! Creating points and line layer is just as easy – you simply need to define the type of layer when you create it, and of course you can only create point in point layers and lines in line layers.
As we mentioned previously, a shapefile is a commonly used geographic file format. It can easily be converted into other formats, and most GIS software can read this type of file. You may notice when adding a shapefile that there are numerous files in your shapefile directory with the same name. This is because a shapefile actually relies on a collection of several other files to store the data and keep various settings. When you add a shapefile to your project, you should always add the one that ends in .shp, but the rest of the files are important too!
Shapefiles (and other types of files) are one way to store geographic data. You can also load a vector layer into QGIS from a database. You may already be familiar with Database Management Systems (DBMS) such as Microsoft Access. GIS applications also make use of databases to store geographic data. Databases can be hosted and used locally on your computer, or could be shared between users over a network or even the internet.
Remember frequently to save your map! Your QGIS project file does not save the data (data is saved in a shapefile or a database), but it does remember the layers that you have added to the project, their order, and any settings that you adjust.
The symbology of a layer is its visual appearance on the map. One of the basic strengths of GIS is that you have a dynamic visual representation of the data you’re working with. Therefore, the visual appearance of the map (which depends on the symbology of the individual layers) is very important. The end user of the maps you produce will need to be able to easily see what the map represents. Equally as important, you need to be able to explore the data as you’re working with it, and good symbology helps a lot.
In other words, having proper symbology is not a luxury or just nice to have. In fact, it’s essential for you to use a GIS properly and produce maps and information that people will understand and be able to use.
To change a layer’s symbology, we will open its Layer Properties. Let’s begin by changing the color of the pemukiman layer.
By default you can also access the Properties menu by double-clicking on the name of the layer.
This is good stuff so far, but there’s more to a layer’s symbology than just its color. Next we want to change the color of the vegetation, but we also want to eliminate the lines between the different types of vegetation so as to make the map less visually cluttered.
Sometimes you will find that one of your layers is not suitable for a given scale. For example, if you have a layer which shows the earth’s continents but not with very much detail, the continent lines may not be very accurate when you are zoomed in very far to see streets.
Scale is a reference to how your map references what is actually on the ground in terms of size. Scale is usually given in terms like 1:10000, which means that one centimeter of length on your map is equal to 10000 centimeters in the real world. When you zoom in or out on a map, the scale changes, as you can see in the status bar at the bottom of QGIS.
In our case, we may decide to hide our streets layer when we are zoomed out very far (a small scale). For example, the streets layer is not very useful when we are zoomed out far and it looks like a blob.
Let’s enable scale-based rendering:
You can use your mouse wheel to zoom in increments. Alternatively, use the zoom tools to draw a box and zoom to it:
Now that you know how to change simple symbology for layers, the next step is to create more complex symbology. QGIS allows you to do this using symbol layers.
Now this layer has two different symbologies. In other words, both the green color AND the blue color will be drawn. However, the blue color will be drawn above the green, and since it is a solid color, it will completely hide the green color. Let’s change it.
It’s important not to get confused between a map layer and a symbol layer. A map layer is a vector (or raster) that has been loaded into the map. A symbol layer is part of the symbol used to represent a map layer. This course will usually refer to a map layer as just a layer, but a symbol layer will always be called a symbol layer, to prevent confusion.
Symbol levels also work for classified layers (i.e., layers having multiple symbols). We will cover classification in the next section, but you can see how it works here with roads.
In addition to setting fill colors and using predefined patterns, you can use different symbol layer types entirely. The only type we’ve been using up to now was the Simple Fill type. The more advanced symbol layer types allow you to customize your symbols even further.
Each type of vector (point, line and polygon) has its own set of symbol layer types. First we will look at the types available for points.
Once you have applied the style, take a look at its results on the map. If the dots not shown up, check the advanced setting and go back to Symbol level. Change the upper symbol layer to “2”. Then click OK. As you can see, these symbols change direction along with the road but don’t always bend along with it. This is useful for some purposes, but not for others. If you prefer, you can change the symbol layer in question back to the way it was before.
As a result, you have a textured symbol for the urban layer, with the added benefit that you can change the size, shape and distance of the individual dots that make up the texture.
By classifying vector data according to their type, we can give them different symbologies and they will still appear to flow into each other.
So, this is useful! But it hurts your eyes to look at it, so let’s see what we can do about that.
You’ll notice they don’t have outlines. This is because because you just removed the outlines!
If you feel confident in your new classification skills, try to classify the residential layer yourself. Use darker colors to distinguish it from vegetation.
In the previous example, we classified the vegetasi layer by what is known as nominal classification. This type of classification is when categories are defined based on names. Next we will classify the pemukiman layer based on the size of each feature. Classifiying with attributes that contain only positive numbers, such as land area, is known as ratio classification.
Now you already know how to symbolize vector data into various types. You can try to symbolize another data such as line or point to make your vector data more informative.
Labels can be added to a map to show any information about an object. Any vector layer can have labels associated with it. Labels rely on the attribute data of a layer for their content.
There are several ways to add labels in QGIS, but some are better than others. You may notice that when you open the Layer Properties window for a layer, there is a tab called “Labels.” While this tab is designed to put labels on your map, it is not nearly as good as the so-called “Label Tool”, which we will learn in this section.
Before being able to access the Label tool, you will need to ensure that it has been activated.
This gives you the Layer labeling settings dialog.
What we have so far is good, but as you can see, the labels are overlapping the points that they are associated with. That doesn’t look very nice. The text is also a bit larger than it needs to be. Let’s fix these problems!
Your labels will now look like this:
Now you can see why we usually need label buffers!
That’s the font problem solved! Now let’s look at the problem of the labels overlapping the points.
Now that you know how labeling works, there’s an additional problem. Points and polygons are easy to label, but what about lines? If you label them the same way as the points, your results would look like this:
This is not very useful! To make lines behave, we’ll need to edit some options.
The map will look somewhat like this, depending on scale:
It’s better than before, but still not ideal. For starters, some of the names appear more than once, and that’s not always necessary. To prevent that from happening:
Another useful function is to prevent labels being drawn for features too short to be of notice.
Here’s the result:
As you can see, this hides a lot of the labels that were previously visible, because of the difficulty of making some of them follow twisting street lines and still be legible. You can decide which of these options to use, depending on what you think seems more useful or what looks better.
Now that you know how attributes can make a visual difference for your map, how about using them to change the symbology of objects themselves? That’s the topic for the next section!