Documente Academic
Documente Profesional
Documente Cultură
2016
Introduction
This will be my fifth book on QGIS in Swedish, and this time it is a complete
rewrite of all content. The book is written based on the QGIS 2:14 LTR
(released February 2016), which is a so-called "Long Term Release" to be
maintained for longer and thus more suitable for production environments
or programs.
In previous books as the beginning been designed so that beginners will
quickly get started with QGIS, and so is this book structured.
Part 1 is a quick start as a short cut quite a lot of curves, but to give an
introduction to enough features to anyone with little computer knowledge
to be able to start working with GIS.
In Part 2 will then a recess where even more features are introduced, which
means that this part is more extensive.
part 3 going into the more practical work with GIS and includes processing
and analysis of geographic data.
The book concludes with a number of exercises related to each part, which
you can use to train on it as described in the book. You are also advised to
find on their own data in order to further try it raised.
Once you have gone through the whole book so you will hopefully have an
excellent foundation to build on when you proceed with GIS work,
regardless of whether you "just" want to do some household use maps, or to
use QGIS in a professional context. For all that the book does not take up so
there's lots of information and forums on the Internet, not least my own
blog
http://geosupportsystem.wordpress.com, but also additional literature
mainly in English.
grounds
Before we get going with the program itself, here are some basic
information. Are you impatient and already have QGIS installed, so you can
jump directly to the fast start of Part 1.
What is QGIS?
QGIS is an advanced GIS (Geographic Information System) for managing
maps and other information with a geographic position. With QGIS you can
open and view geographic data, but also create your own store and build
maps of the computer screen or print.
QGIS is based on "open source" or open source. This
means that unlike commercial or closed-source
software has those who want full disclosure of all
program elements. A natural consequence of this is that
the software based on open source in most cases is free,
so even QGIS. Another characteristic of open source is
that the trend is being driven by users that can engage
at different levels. Everything from clean source
programming to the translation of the interface and the
reporting of bugs.
Since the software is free so do developments financed in other ways. One
way is that users themselves are developing software, the second way is to
use sponsorship or donations. Even small donations can have a huge impact
on an open-source programs. Missing the functionality of the program, you
can go in and sponsor the development of that particular feature, which is
rarely possible for software closed source.
A major advantage of QGIS is that it does not matter if you use Windows,
Mac or Linux. The program is available for all of these operating systems,
and works the same way.
Installing QGIS
The website http://qgis.org there is a
link on the first page to download the
QGIS. There are also instructions for
installation works.
Sdan detects your operating system and
activates instructions adapted to this.
Would this be wrong, or if you want to
download files for another
OS so it can be changed directly in the
interface.
In this book, so we assume QGIS 2.14, which is a "Long Term Release". These
LTRversioner released once a year and get support in the form of bug fixes
mm longer than the other versions. Between these LTRversioner then
released both stable versions "trial versions" which introduces new features
and testing concepts that might come in the next version LTR. Smooth
version number (like 2:14 and 2:16) are stable versions, while odd numbers
are trial versions that are continuously updated as advances.
The book uses the Swedish version of the interface, which does not mean
that absolutely everything is translated 100%. There are parts, not least
among the various additions and help instructions, that simply does not
translate. If you'd rather use QGIS with English interface, or another
language, so can this be set in the application settings.
Windows
For Windows, the easiest way to download the standalone installer package
in 32 or 64 bit version. With this installed all files and dependencies, and it
would take something extraordinary to get direct information.
If you want more control, or perhaps install trial versions of QGIS you can
use OSGeo4W. With this, you can not just install QGIS, but also a variety of
other GIS applications based on open source.
Mac
For Mac, is the setup files on a separate page. If you choose LTRversionen so
are all required packages included, but a number of Python
3
Geodesy
(Greek: geo - earth, daiein - sharing)
What is Geodesy and why do you need to know anything about it?
Everything is basically that the earth is not flat, or even have a form that can
easily be described by a mathematical formula. This makes it difficult to
transfer objects on the earth surface to a map.
Download Data
For this book is used mainly open data from the land survey. These are
available to download via http://lantmateriet.se under "Open Data".
These data are published under a license called "Creative Commons" which
is a relatively simple system for sharing information on the Internet. The
6
menu
Via the menu, you can access most functions or activate buttons and panels
that are currently not visible. During the project menu, we find features to
create new projects or open the old, but also commands to save the project,
create and print layouts and exit the program.
Creating new projects, open, save and create layouts can also be accessed
via the toolbar "Files".
Status bar
At the bottom of the program's status bar. It displays information about
what you do or what is shown, for example, information about the
coordinates and scale. It is also possible to change the coordinate system,
which we will return to in other chapters of the book. You can also show and
hide the log messages of different types with a button. Note that the button
changes its appearance depending on whether there is new information in
the log that you have not seen.
map Window
This is the map itself. To get started and we will begin by adding a "layer" of
the map that we download from the Internet.
There are many different types of bearings and many ways to add these. The
stock we start with a WMTSlager, or Web Map Tile Service. By clicking on
the button "Add WMS / WMTS stock" (mouse over the buttons to display
the name of the button) to open a dialog where you have to make some
9
settings. The dialog box is available for all buttons that add layers, but look
different depending on what is the type of stock.
To use the Internet stock so we need some information about the layer to be
used. On Lantmteriets website provides information about the open data
that we will use in this book and for the first layer, we use a urladress.
http://mapsopen.lantmateriet.se/open/topowebb
ccby / v1 / WMTS? request = GetCapabilities & version = 1.0.0 & service =
WMTS
(If the above address is not working to get the controls to Lantmteriets
website if it has changed since the book was written.)
This URL is used together with an appropriate name when a new connection
is created. Other settings in the dialogue, we can skip that long.
Once set up, we can click on "Connect". Depending on what is the type of
stock that will be available stock is displayed in a list. In this case, it is a layer
10
under the "Tile sets". By selecting a stock, you can then click on the "Add"
button to add the layer in QGIS. If you want you can choose to set a new
name for the layer to be added first.
Many dialogs QGIS does not close automatically, so when layer added as we
get close the dialog manually.
11
Vector stock available in various formats, but here we mainly use two types.
Temporary sketch layers and layers in the format "shape". You simply create
their own stocks of these types with a toolbar button "Managing layers".
There is an optional button that can create both temporary sketch layer as
shapefiles and spatialitelager, which is another type of vector layers.
Shape files saved on the hard disk and are maintained even if you quit QGIS.
Temporary sketch stock is only in memory and will disappear if QGIS
terminated.
Start by creating a temporary sketch
layer. Select the type Paragraph dialog
box and rename the layer to "Lakes".
Selection of coordinate system we will
return to, but is not really important
right now.
The layer you created ends up in the
list with the other layers, in the panel
"Layers". In this list are all the map
layers and they are listed in the order
they appear on the map. A layer that is over another in
list, shown above this layer in the map. You can reorder the layers by
dragging them with the mouse.
Stock has a small pencil icon
by
themselves, which means that it is
To edit the layer. There is a toolbar with a corresponding button
(Digitization) used to switch a layer's editing mode. To switch the edit mode
can also be done by right clicking on the layer.
The toolbar has several buttons, not least in order to "add items" by clicking
on the map. Wait a minute to click on this, because we first need to add
some object properties or attributes of the table. Right-click the layer Lakes
and select "Open attribute table".
12
Right now, the table is very empty, so we should add some attributes. Click
on the "New field" and give the attribute name "name" and select the type
"text". Other fields in the dialogue, we can skip that long. Also add a field
called "height" of the type "Integer" (try to avoid , , in the field name).
Close the table when finished.
Now you can pan and zoom the map to an area that interests you. Use the
"Add Item" and click in a lake on the map.
This creates a point where you clicked open a dialog with the fields in the
attribute table. Here you fill in the lake's name and if there is a height
specified in the lake
will fill you in it too.
Many lakes have no
specified depth, but
has a height indicated
that tells you how
high above the ocean
surface are.
None of the fields are
"Imperative" so if you
do not have to fill in a
field, you can skip it.
13
Layer Styles
When creating layers of points, lines or surfaces, you get a standard
appearance of these objects. To change this appearance so you have to go
into each layer's properties. This can be done by right-clicking on the layer
and choose properties, but a double click on the layer tend to go fastest.
Start with layer "lakes".
In nature, there are several tabs which we will look at later, but take the
opportunity to click on them to get an idea of how the program is
structured.
15
Begin to change the existing symbol layer from Single marker to sign marker.
Choose a suitable font and the letter "S". Select a blue color, and as 4
millimeters (or other suitable size).
Add a stock symbol in character the cursor and select "Simple marker" as the
type. Use a square icon with white fill and blue border. Put the size to 5
16
millimeters and border width to 0.5 mm, adjust if necessary size to the "S"
character fit inside the border.
17
The fill color for markers set to the same red color as the line and border
style is chosen "No line". Does the size of the right size and rotate the
marker both symbol layers to point out from the line. Does the board
(including arrows) transparent by 30% by putting the layer's opacity. When
you are done, you can preview the "Apply" button and click "OK" when it
looks good.
Labels
In stock performance, there is a tab labels. These work in a similar fashion to
style, then you start by selecting a label category. There is not as much to
choose from and now it is sufficient to simply select the "Show labels for this
layer." We begin with a point layer with the lakes.
Select the "Ticket to" attribute "name". Choose a suitable font properties in
the "Text". You can select, for example, style, size and color. Choose a bold
style, size 12 points and the same blue color as before.
Jump to "buffer" and choose to draw the text buffer. This should be 0.8
millimeters wide and white.
You can view all changes in the map by pressing the "Apply" button.
18
The placement of the text is determined by the program, but under the
"Placement" you can determine the "exact position from the point." In this
case you should, however, choose "Cartographic" position and the "Offset
Distance from - symbolic boundaries". This means that the label is
automatically placed in a convenient place and at a suitable distance from
the point symbol.
Create labels for polygonlagret Cities. Use a thin, black, a little bigger italics
without buffer, but experiment with the settings for "Shadow" and
"separation" of letters (in text settings). Also choose a "Placement" that suit.
For line store, we will create a little more complicated etiquette. Instead of
directly selecting either "slot1" or "plats2" as the source for the label, and
we will build an expression for the label. Expressions dialogue started with
the button with "" sign (epsilon) to the right of the field "Ticket with". This
dialogue occurs in many places in QGIS, and makes it possible to build more
or less advanced expressions that can be used in several contexts. Now we
use it to turn the contents of two attributes. In midfield expanded "Fields
and Values" and where we double-click first on "slot1" then
"Plats2". This adds to these in the left panel. At the bottom it says that "The
expression is invalid," which we must fix and then it will instead be a text to
preview the result of the expression.
Please note that the fields are surrounded by double quotes. We will also
insert fixed texts, which are surrounded by single quotes. To combine fields
and texts as used + or || sign. Add text '' between the two fields, and beat
everything together with the + or ||.
Choose a bold style on the text and insert the same red color as the color of
the line. Experiment with the example buffer and placement until you are
satisfied.
19
Save your map as a new QGIS project. You can do this via the project menu,
save button, or the keyboard shortcut Ctrl + S. If you think you will create
many maps so it can be helpful at this stage to create a separate folder for
these, for example, your document folder. Rename the project file into
something suitable (or "mitt_frsta_QGIS_projekt").
20
When you added your item inventory with the "Open" you will notice that
the style you set up earlier are gone. That's because the "style" is not saved
together with the layer data, but it is to fix.
Open the previously saved project, either
through Project menu, "Open" button or
keyboard shortcut Ctrl + O. For every stock that
you previously created yourself, you should
open the layer properties (double-click on the
layer) and click the "Style" at the bottom of the
window. Select "Save as default". This creates an
EndNote stored in the same location as the
inventory files with the same name but with the
extension "QML".
After you save all the layer styles as standard so you can again create a new
blank project (Ctrl + N).
21
Now you can add the item layer by lakes with the same button as before and
then the saved style used by default.
Add the surface layer of cities via the menu "Layer" or the keyboard shortcut
Ctrl + Shift + V.
Line layer should we add in a different way. Use the panel "Data Sources". If
it is not visible, right-click in utilities and activate it. Here, find the layer with
the "straight line" on the path where you chose to save it. Note that QGIS
recognize that this is a vector layer and therefore does not appear all files
layer actually consists of.
Add layer by dragging and dropping it on the map. Drag and drop works with
all layers QGIS recognize, as well as with project files.
If you look closely at your map and you'll see it a little differently. It is to your
vector layers are saved in a oprojicerat coordinate system. To correct the
22
appearance so that it complies with the former, you can change the project
settings to a projected coordinate system is used instead.
Click the button to coordinate the text at the bottom
right of the status bar.
Enable instant coordinate transformation, enter the text "3006" in the filter
field and select "SWEREF 99TM" in the list, followed by "OK".
Save the project under a new name. Close QGIS and open the application
again.
When you start QGIS so will your latest project, along with a preview and
description appear on the homepage. To open one of these you can doubleclick it. Open your first project with the background map from the land
survey.
23
Create layout
Now we will make clear a map with its
layout so that it can be exported to
PDF or printed on paper. It is already
exporting the map image to a
standard image, for example, jpg or
pngformat. You do this in the project
menu with the option "Save image as
...".
To contrast, create a layout, you can use the Project menu and choose "New
Print Layout". You can also use the keyboard shortcut Ctrl + P.
You can give the layout a name, but if you do not, it creates a name
automatically.
Layout is a "support programs" to QGIS reminiscent of other programs that
also handles graphics. Even Layout contains toolbars and panels that can be
switched on and off, or moved around the interface.
To begin with, the layout is empty and the surface corresponds to a paper
size. This can be changed on the tab "Composition". You can use the preset
as A4, or set the size freely.
The layout has a corresponding tool to zoom and pan in
24
map window. It is possible to add specific items to the layout, but also
simple geometric shapes and texts.
Start by adding a feature by clicking on the button "Add New Map" and then
click and drag out an area where you want to place the new map.
The map drawn out adapted to that shown in the map window in QGIS. You
can zoom and pan the map, but now it is important to distinguish between
layout and map. The tools in the layout program handles layout. If you want
to manage the content, for example, a feature that you first choose the tool
"Move element contents".
Each element that is added to the layout has its own characteristics. These
are available in the panel "Element Properties". Add a frame to your map in
the properties of the feature.
Add a new label with the label button. This is done in the same way as for
the map by clicking and dragging out an area in the layout. The element
properties, you can edit the text content as well as font and alignment. Use
the label as a heading on the map and give it an appropriate name.
Add a legend to describe the symbols of the bearings used. By default, all
layers. This can be changed by removing the "Update Automatically" in the
element properties. Then you can select and delete individual layers from
the legend of the button with the red minus sign.
You can edit the text in the legend, select the layer and click the "Edit text
element". You can also change the title, alignment, and font for all parts of
the element. If you have a long list of symbols in the legend so this can also
be broken down into several columns.
Add a scale bar to the layout. Use the style "line dash up" and adjust the
elements properties in general so that lines, fonts and display fits your map
in general.
Round by adding a frame around all map elements. This is easily done by
adding a rectangle without filling.
25
Finally, you should add a text box with a small font. From this text, it must be
stated that the background map from the National Land Survey and used
with the CC BY license.
Background map from Lantmteriet CC BY
Then just export to eg PDF or print to a printer.
You have now created your first map and before going further, it is
appropriate to repeat all the steps, try a little more freely and to choose
other types of vector data to create. If you want, there are exercises at the
end of the book where the opening is a bit simpler, which would fit right
now.
Land Survey data used in this book is distributed under a license called
Creative Commons is a fairly simple license form with simple rules. CC BY
26
simply means that you may use this data as you wish, as long as you specify
that it is the National Land Survey is the source.
Do you use other data on your products, you need to find out which terms
and conditions that apply to them. Create your own data so you can decide
which conditions apply to the use. Just be aware that if you use National
Land Survey data only source to produce new data, it is not you who is the
source, but it is still the Land Survey.
You must, therefore, be a bit careful when creating maps that you want to
spread further. Are there maps for use at home or at most limited
distribution, it usually does not pose any major problems in the long run.
The rest of the book, we will use both Lantmteriets background map (in this
chapter) as files in raster and vector formats. Want to try a little self with
different types of data, you can now take the opportunity to download the
data and save them on your hard drive, for example, in a directory called
"geodata". Then you can sort the data in subdirectories that "breaks",
"vector" and "hojddata".
QGIS has an interface in Swedish, but sometimes there can be problems
when above all paths contain Swedish teckan as , , . Therefore, it may
help if you avoid these characters and spaces in all paths, but you do what
you want.
At the address ftp://downloadopendata.lantmateriet.se/ example, you can
download:
GSDOversiktskartan vector (use the "shape")
GSDSverigekartan breaks (use "GeoTIFF")
GSDSverigekartan vector (available for several different scales - use the
"shape")
GSDHojddata grid 50 plus (downloadable county - use the "nh" and not
"HDB")
There are also more detailed maps, but for the book's purpose, it is enough
if you have the above available.
To access the FTP path above require a login, this is provided free through a
registration at Land Survey website
(http://www.lantmateriet.se/sv/Kartorochgeografiskinformation/Kartor/opp
nadata/hamtaoppnageodata/).
27
If the addresses above does not work, you can try searching for "Open Data"
on Lantmteriets homepage.
28