GIS AH C3: Perbedaan revisi

(50px Follow along: Loading vector data from shapefiles)
(What's next?)
Baris 383: Baris 383:
  [[GIS_AH_Answers#Results_for_Working with Vector Data|Check your answers]]
  [[GIS_AH_Answers#Results_for_Working with Vector Data|Check your answers]]
{{example|Click here to go to [[GIS AH C4|Module 4 : Classifying Vector Data]]}}
{{example|Click here to go to [[GIS AH C4|Module 4 : Classifying Vector Data]]}}
{{example|Click [[GIS_Animal_Health:English|'''here''']] to go back to the list of Modules}}

Revisi terkini pada 31 Oktober 2014 08.07

Module: Creating a Basic Map

In this module, you will create a basic map which will be used later as a basis for further demonstrations of QGIS functionality.

Lesson: Working with Vector Data

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.

Basic4.png 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 streets 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:

  • Click on this button:


It will show you a table with more data about the streets layer. This extra data is called attribute data. The lines that you can see on your map represent where the streets go; this is the spatial data.

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.

Basic.png Follow along: Loading vector data from shapefiles

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.

Check your results

Basic4.png Follow along: Loading vector data from a 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 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.

  • Click on this icon:


(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 dialogue. In this dialogue:

  • Click the New button.
  • In the same folder as the other data, you should find the file land_use.sqlite. Select it and click Open.

You will now see the first dialogue again. Notice that the dropdown select above the three buttons now reads "land_use.sqlite@...", followed by the path of the database file on your computer.

  • Click the Connect button. You should see this in the previously empty box:


  • Click on the layer to select it
  • Click Add

Note: 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.

Check your results

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.

Note: 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.

For example, this layer order...


... would result in some places being hidden as they run underneath the land_use areas.

To resolve this problem:

  • Click and drag on a layer in the Layers list.
  • Reorder them to look like this:


In conclusion

Now you've added all the layers you need from several different sources.

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 colours and symbols. This is what you'll learn to do in the next lesson.

Lesson: Symbology

The symbology of a layer is its visual appearance on the map. The basic strength of GIS over other ways of representing data with spatial aspects is that with GIS, 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 be able to use.

The goal for this lesson: To create different symbology for any vector layer.

Basic4.png Follow along: Changing colours

To change a layer's symbology, open its Layer Properties. Let's begin by changing the colour of the waterways layer.

  • Right-click on the waterways layer in the Layers list.
  • Select the menu item Properties in the menu that appears.

Note: By default, you can also access a layer's properties by double-clicking on the layer in the Layers list.

In the Properties window:

  • Select the Style tab at the extreme left:


  • Click the Change button next to the colour label.

A standard colour dialogue will appear.

  • Choose a blue colour and click OK.
  • Click OK again in the Layer Properties window, and you will see the colour change being applied to the layer.


Basic4.png Try yourself...

Change the forest layer to a new colour that you associate with forests.

Check your results

Basic4.png Follow along: Changing symbol structure

This is a good introduction, but there is more to a layer's symbology than just its colour. To learn about some of the other options available, add the layer bandung_districts.shp. This layer has been made up of images originally taken by satellite, and showing various types of land cover in the area around Bandung.

Using this layer we can learn how to remove the lines so the map does not appear cluttered.

  • Open the Layer Properties window for the bandung_districts layer.

Under the Style tab, you will see the same kind of dialogue as before. This time, however, you're doing more than just quickly changing the colour.

  • Click on the Change... button below the colour display:


The Symbol properties dialogue will appear.

  • Change the colour inside the polygons in the layer by clicking the button next to the colour label (if you haven't done so already during the previous lesson).
  • In the dialogue that appears, choose a new colour.
  • Click OK, but only once.

Next, we want to get rid of the lines between the different types of land cover.

  • Click on the Border style dropdown. At the moment, it should be showing a short line and the words Solid Line.
  • Change this to No Pen.
  • Click OK, and then OK again.

Now the bandung_districts layer won't have any lines between the different areas of land cover.

Basic4.png Try yourself...

  • Change the bandung_districts layer again so that it has dotted outlines which are just a bit darker than the fill colour for that layer.
Check your results

Moderate4.png Follow along: Scale-based visibility

Sometimes you will find that a layer is not suitable for a given scale. For example, a dataset of all the continents may have low detail, and not be very accurate at street level. When that happens, you want to be able to hide the dataset at inappropriate scales.

In our case, we may decide to hide the streets from view at small scales. This map, for example ...


... is not very useful. The streets are just a blob at that scale.

To enable scale-based rendering:

  • Open the Layer Properties dialogue for the streets layer.
  • Activate the General tab.
  • Enable scale-based rendering by clicking on the checkbox labeled Use scale dependent rendering:


  • Change the Maximum value to 100000.
  • Click OK.

Test the effects of this by zooming in and out in your map, noting when the streets layer disappears and reappears.

Note: You can use your mouse wheel to zoom in increments. Alternatively, use the zoom tools to zoom to a window:


Moderate4.png Follow along: Adding symbol layers

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.

  • Go back to the bandung_districts layer's Symbol properties dialogue as before.

In this example, the current symbol has a dotted outline (i.e., it uses the Dot Line border style).


Note the highlighted button.

  • Click on it and the dialogue will change to look somewhat like this:


(It may appear somewhat different in colour, for example, but you're going to change that anyway.)

Now there's a second symbol layer. Being a solid colour, it will of course completely hide the previous kind of symbol. Plus, it has a Solid Line border style, which we don't want. Clearly this symbol has to be changed.

Note: 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.

  • Set the border styles to No Pen.
  • Change the fill style to something other than Solid or No brush. For example:


  • Click OK in this dialogue and Apply in the one after that. Now you can see your results and tweak them as needed.

You can even add multiple extra symbol layers and create a kind of texture for your layer that way.


It's fun! But it probably has too many colours to use in a real map...

Moderate4.png Try yourself...

  • Create a simple, but not distracting texture for the forest layer using the methods above.
Check your results

Moderate4.png Follow along: Enabling symbol levels

When symbol layers are rendered, they are also rendered in a sequence, similar to how the different map layers are rendered. This means that in some cases, having many symbol layers in one symbol can cause unexpected results.

  • Give the streets layer an extra symbol layer (using the method for adding symbol layers demonstrated above).
  • Give the base line a thickness of 0.5.
  • Give the top layer a thickness of 2.0.

You'll notice that this happens:


Well that's not what we want at all!

To prevent this from happening, you can enable symbol levels, which will control the order in which the different symbol layers are rendered.

  • In the Layer Properties dialogue, click on Advanced \rightarrow Symbol levels:


The Symbol Levels dialogue will appear.

  • Alter its values to match this example:


  • Click OK, then OK again.

The map will now look like this:


When you're done, remember to save the symbol itself so as not to lose your work if you change the symbol again in the future. You can save your current symbol style by clicking the Save Style ... button under the Style tab of the Layer Properties dialogue. Save your style under exercise_data/styles. You can load a previously saved style at any time by clicking the Load Style ... button. Before you change a style, keep in mind that any unsaved style you are replacing will be lost.

Moderate4.png Try yourself...

  • Change the appearance of the streets layer again.

The roads must be dark gray or black, with a thin yellow outline, and a dashed white line running in the middle to make them resemble a real road.


Check your results

Hard.png Try yourself...

Symbol levels also work for classified layers (i.e., layers having multiple symbols). Since we haven't covered classification yet, you will work with some rudimentary preclassified data.

  • Create a new map and add only the streets dataset.
  • Apply the style advanced_street_style_demo.qml provided in exercise_data/styles.
  • Zoom into the layer so it is easier to see.
  • Using symbol layers, ensure that the outlines of layers flow into one another as per the image below:


Check your results

Moderate.png Follow along: Symbol layer types

To continue with the exercise, open your original map again.

In addition to setting fill colours 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.

Point symbol layer types

  • Change the symbol properties for the places layer:


  • You can access the various symbol layer types here:


  • Investigate the various options available to you, and choose a symbol layer type other than the default Simple Marker.

Line symbol layer types

To see the various options available for line data:

  • Change the symbol layer type for the street layer's "residential" layer:


  • Click on the Change button next to the Marker label.
  • Change the symbol properties to match this dialogue:


  • Change the interval to 2,00:


  • Ensure that the symbol levels are correct before applying the style.

Once you have applied the style, take a look at its results on the map. If you look closely, 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.

Polygon symbol layer types

To see the various options available for polygon data:

  • Change one or more of the symbol layer type for the bandung_districts layer, as before for the other layers.
  • Investigate what the different options on the list can do.
  • You can change each symbol by double-clicking on the symbol you want to change


  • In this particularl example we have categorised the data. You will learn more about this in the next chapter.
  • Choose one of them that you find suitable.
  • If in doubt, use a combination of two layers, using the Point pattern fill and a Simple fill:


  • Use the Symbol layer type Point pattern fill
  • The Marker should be a Simple marker
  • Choose an appropriate border and fill colour (this can be the same colour)
  • Choose an appropriate marker size
  • Click OK
  • Add a new symbol layer with a normal Simple fill.
  • Make it a contrasting colour to your first layer
  • Move it underneath the point pattern symbol layer with the Move down button:

As a result, you have a textured symbol for your chosen layers, with the added benefit that you can change the size, shape and distance of the individual dots that make up the texture. The following screenshot shows we have changed two layers using the above method.


In conclusion

Changing the symbology for the different layers can 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!

You can even create your own, custom SVG fill using vector editing software such as Inkscape, which is freely available on the internet.

Further reading

Examples of Beautiful Maps[1]

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?

Check your answers

Click here to go back to the list of Modules