Sei sulla pagina 1di 7

INTRODUCTION TO QGIS

gdburns@gmail.com, April 2008

BACKGROUND

This is an introduction to QGIS 0.9.1, a program that can manipulate geographical Another type of map data is called raster data. Two examples are satellite images
data and display the results on screen. It draws maps, in other words. The initials and aerial photographs. QGIS can import rasters. Instead of the shape of a river
stand for Quantum Geographical Information System. GIS is the general term for appearing on your map you will see an actual photo that aligns perfectly with the rest
these types of programs. of the map. I will not be describing how to use raster data in this introduction, mainly
QGIS can be downloaded free of charge (freeware) from this site. It is available because I don’t know how to do it. If anyone reading this knows the trick, please
for Mac, PC and other platforms. This introduction is written for the Mac, but the email me instructions, including sample data suitable for use with the map shown in
majority of it is applicable for PCs as well. QGIS is not the only freeware GIS these notes. But please check that it works with this map.
program: Now, back to shapefiles. Three folders of shapefiles are included with this
package:
• GRASS (several platforms) has been in development since 1982. It is a powerful
program, but difficult to master. You need a certain level of skill to even open it (or • Coastline of Australia
the right software, such as OPENOSX GRASS). • Rivers & Creeks
• State Boundaries
• ARC EXPLORER (PC & Mac) is for education. It allows you to view maps, but you
cannot do much manipulation with the map data. The way it operates is very similar If you look inside the Coastline of Australia folder (the other two folders contain
to QGIS, though QGIS is more powerful – and more unstable (it has more bugs). similar files), you will see four files typical of the shapefile format:
• TATUKGIS Free Viewer – PC only. And since I’m a Mac man, I can’t comment on • Coastline.dbf – a database that contains details (‘attributes’) of the features;
it. • Coastline.prj – describes the map projection;
• Coastline.shp – contains the shape of features (lakes, rivers, and so on);
The power of these programs lies not in the ability to draw maps – most drawing • Coastline.shx – index file.
or image programs could be used to draw a map – but in their ability to use data to
draw maps automatically under your control. There are lots of varieties of map data, By using QGIS and the data in these folders, you will be able to draw a simple
but I will be using only one type to demonstrate how QGIS works: ESRI shapefiles. map of Australia if you follow these notes. The map will include state boundaries
Some government mapping agencies, such as Geoscience Australia, make this data and a small number of rivers. One feature will be added at a certain latitude and
freely available. longitude. Then the instrucitons will describe how to save the map to an image file so
Shapefiles are a type of data called vectors, a commonly used word in QGIS. that it can be emailed or used inside a text document.
A vector is a word that simply means you need at least two numbers to describe a I have tried to design these instructions so that anyone with a basic knowledge
certain item. Your speed when driving, for example, is not a vector because it only of computers but no knowledge of GIS, can draw a simple map. I hope that what
needs one number: 80 km/h. On the other hand, to locate the Sydney Opera house took me four days – searching on the internet for programs and data, and scratching
needs at least two: latitude and longitude; and three, if you want to know its height my head in front of my computer – will be reduced to an hour or so for anyone who
above sea level. To describe the shape of a coastline, a river, a lake, or the position of works through these instructions. And I hope you will be surprised how easy it is.
towns and mountains, requires lots of numbers. A shapefile is a long list of numbers This is only an introduction. What you see here is my total knowledge of QGIS.
(vectors) that tell QGIS how to draw features on a map. I don’t know anything about rasters or projections or other data formats. For more
detailed information you’ll have to go to other sources.
WHY USE QGIS? WHAT YOU NEED TO MAKE A MAP
In my case – to draw maps to illustrate the routes of early explorers in Queensland. You will need QGIS from the QGIS website, and the shapefiles as described
There is no quicker way to bore a reader than to reel off a list of place names, mountains previously (Coastline of Australia, etc) which are included with this zip package.
and rivers. A simple uncluttered map has the power to bring a geographical story to QGIS is a bit fussy about where the shapefiles are located. On the Mac, for
life in a way that even a thousand words can’t do. I used QGIS to generate a base map instance, it can’t find files that are on external firewire drives (unless you have typed
of Queensland with all the features that I needed, then I selectively zoomed in or out in /volumes in the File Name field). For this introduction I suggest you create a new
and incorportated only those features I needed for a particular map. Basically, I drew folder called Mapping, and copy the shapefiles and QGIS to that folder.
one map and manipulated it to draw all the others, about 30 in total. One more thing about location. QGIS calls making a map, a project, and it does
The completed maps (see the PDF file Samples, included with this zip package) not store the map data within your project. It remembers where the data came from and
were not output directly from QGIS – it does not have the capability or flexibility to looks for it there every time you open the map. If you move the shapefiles somewhere
draw a finished map of the type I wanted. Rather, I used QGIS to generate the map else (because you don’t like them within the folder Mapping, for instance), or you
features (mountains, rivers, towns) which I then used as a template. In other words, I rename the files, QGIS will ask you where they are, and you will have to tell QGIS
spent a few minutes and traced over the top. My maps were simple enough to allow where every single file is that you have moved. And that brings me to the first bug
me to do that. In a few cases I did use the QGIS output, for example, when I wanted within QGIS 0.9.1 (assuming it has carried over from 0.9):
to use detailed contouring or a complicated river system as a background.
If there are more than 5 or 6 files it can’t find, it will crash.

There is another bug that requires QGIS and the data it is using to be on the
same hard drive. If you have partitioned your hard drive, QGIS and its data must be
on the same volume. If they are not, you will have problems editing. On the Mac,
the easiest way to ensure you have no problems with this introduction is to put
QGIS and its shapefiles within the folder Mapping (or any folder you like).
QGIS WINDOW
The first time you open QGIS, it won’t look like this. This is what we
are aiming for. I suggest you resize the entire window to fit on screen, then
resize the individual windows to suit
yourself. There are three windows:

• Map View – shows you the map you


have made; The Map View window. This is your map area.
• Legend - shows the layers from Resize it with the little black dot on the left.
which you made the map;
• Overview – the red outline shows
what proportion of the entire map
data you are viewing.

Most of the operations in QGIS use


the icons in the toolbar. They are just
below the menu bar, and are reproduced Legend – in this window are listed all
at the bottom of this page. I won’t go the layers that go to make up your
map. A tick means a layer is being
through them here. It is best to run your displayed. There will be nothing in
mouse over each toolbar icon at the top this window when you first start.
of QGIS (a litttle name will pop up after
A layer on top may block out others
a second or so) to see what each one underneath. If that happens, move
does. If the toolbar icons do not all fit it to the bottom by clicking and
dragging.
across the screen, a gray double-arrow
pointing to the right will indicate that
more icons are available. Click on the
gray arrow to see them.
I may indicate which actions are to
be performed by using the menus. For
example, File > Print > General means
Overview window. The square-ish red box
select File, then Print, then General. corresponds with the square-ish Map View
I will indicate the use of a toolbar window at the right.
icon by using bold: Add a Vector Layer
(the sixth icon from the left in this case).
You can search for a particular toolbar icon by running your mouse over
the top of the icons. It doesn’t take long to remember what they all are.

Below: The toolbar icons with which most


actions in QGIS are performed.
Adding Layers
A layer is added to the map by selecting Layer > Add a Vector Layer, or
by choosing the toolbar icon Add a Vector Layer, or by simply typing ‘V’. A
window similar to that shown on the right should appear. It is asking you: Where
is the shapefile you want to add? Navigate to the Coastline of Australia folder.
Double clicking on that folder should show four files in the window. Three will be
grayed out, and only one, Coastline of Australia.
shp, will be active. Click on it, select Open, and
you should now have the first layer of your map
showing in the Legend window. In the Map View
window a map of Australia should appear as
shown on the right.You can toggle the map on and
off by clicking on the tick box on the left of the
Coastline of Australia layer.

Another bug: if you click in the centre of the


tick box nothing happens. You have to click to
the left of centre, or even outside the box.

Changing Layer Properties • Metadata shows you the attributes of the


You can change the color and thickness layer. You won’t see many useful attributes
of the lines that make the map, and you can for the coastline, but for other layers such
change the fill color, by double-clicking on as towns and rivers (not included with this
introduction) the names of all the towns
the layer name, Coastline of Australia, in the
and rivers can be displayed on the map;
Legend window. This will bring up a Layer
Properties box (left). By double-clicking • under Labels you can chose to show the
on the colored boxes (to the right of Outline names of towns and rivers if you have
color and Fill color) you can change the color. those particular layers added to the map
I suggest making both colors quite pale so (but only if the layers have names included
that the layers to be added on top can be seen as an attribute).
clearly. To see how Labels works, tick the
Many other options are available from the Display labels box (just underneath the
Layer Properties box. I will not go through box it should indicate that AREA will be
displayed), click OK, and your map will
them here, except to say that:
be covered with AREA information. Now
remove this unnecessary information by
• under General you can change the name of
going back and unticking the Display
the layer;
Labels box.
Add the following layers by navigating to the Adding Your Own Features 3. Click on OK again, and QGIS will present you
indicated folder, then double clicking on it and Here’s how to add a layer to indicate the camp of with a Save As window. It is asking you: What
selecting the appropriate shapefile from within. Duncan McIntyre when he camped on the Flinders do you want to call this new shapefile and where
Remember, you have to navigate all the way until River in March 1865. This new layer has just one do you want to put it? For the File Name type in
‘Camp McIntyre’, then click Save. You have just
you see a gray shapefile ending with ‘.shp’ and then point: Longitude 141.12ºE, Latitude 19.64ºS. The
created a blank shapefile into which we are going
opening it. Only a shapefile will generate a new layer. campsite will be added to a new layer so that I can to enter the latitude and longitude.
turn it on and off independantly of other layers (I may 4. To add a point to this new layer, click on the
• State Boundaries not want it on all my maps). layer’s name to make it active, then click on the
- State Boundaries.shp icon Toggle Editing (it looks like a pencil). This
1. To create a new layer do this: Layer > New Vector allows you to edit the layer.
• Rivers & Creeks Layer, or you can just type ‘N’. The box shown 5. Click on the next icon, Capture Point (again, it
- Barcoo River 2.5M.shp below should appear. looks like a pencil). This icon is poorly named. It
- Cooper Creek 2.5M.shp actually creates a new point on the layer.
- Darling River 2.5M.shp 6. Move the cursor into the Map View window. It
- Flinders River 2.5M.shp should be shaped like a cross-hair. As you move
- Thomson River 2.5M.shp it around, notice that the latitude and longitude
- Towerhill Creek 2.5M.shp are displayed on the lower right of the window.
- Warrego River 2.5M.shp Move to the position 141.12, -19.64 (or any
position you like). You may have to zoom in (use
After you have added each layer you can double the magnifying icons on the toolbar) to be able to
click on its name and change the color and thickness. accurately set the position.
For example, you may want to make the state 7. When you click to select the position, you will be
boundaries gray and the rivers blue. asked to insert a value for the ‘Camp’ attribute you
set up in Step 2. Type anything you like: ‘March
Once you have added these layers you will see 1865’, for instance.
why I want to use QGIS. Given that I am interested in 8. To save the point you have just created, click on
Toggle Editing to turn editing off, and you will be
mapping the routes of the early explorers in Australia,
asked if you want to save. Click yes.
this simple mapmaking allows me to see how the 9. A symbol should appear at the point you selected
explorers jumped from river to river to get from on the map. This symbol can be changed to
south to north: from the Darling, up the Warrego, another type of symbol by double-clicking on the
Barcoo, Thomson, Towerhill Creek, and across the layer’s name in the Legend window and choosing
watershed to the Flinders. Plus, I can use this one a Symbol (from the many on offer) and Size.
map to generate all the different maps I require ( I
would, of course, have added more features than You can continue to add as many features as you
those indicated) simply by zooming in or out if I want like to the new layer.
to show details of certain parts of their routes. I don’t
have to draw a new map each time. 2. Select Point, ESRI Shapefile, and click on Add to
add as many attributes to this layer as you like.
I’ll add just one, with Name = ‘Camp’, and Type =
‘String’. Click on OK to exit this box.
PRINTING WITH PRINT COMPOSER

When you select File > Print, the Print Composer window shown at top right opens up. This
window (General settings) allows you to set the paper size (there are a number of common sizes
that can be selected, other than the Custom size show), and the resolution. The white box is where
your map will appear when you go to the Item settings. In this example, the white box shows a
blank A4 landscape page. To get your map to appear in the window as shown bottom right:

1. Click on Item.
2. Select the Add New Map icon (sixth from right).
3. Draw a rectangle of the approximate size, shape and position where you want your map to appear on
the page. I call this the map box.
4. The whole of the map that appeared in the Map View window before you decided to print, will now
appear centred in the map box you have just drawn. It doesn’t matter what size box you draw, you
always get the whole map. It will just be smaller or bigger, depending on the size of the box.
5. The map box can be moved by clicking inside it and dragging. It cannot be resized with the blue
handles, as you might think. To change size you have to enter the Width and Height in millimetres.

There are two options under Set. The default is Extent (calculate scale). With this setting, the
entire map that you saw in the Map View window (the ‘extent’ of the map) is squeezed into the map
box you drew on the blank A4 page (Step 3 above). You never get anything less than the entire map
– but the scale will change in a complicated way as you change the aspect ratio of the map box. For
example, if you make the map box tall and thin, Australia will get smaller and you will get a lot of
white space above and below your map. All of the map will always be there, but there may also be
white space.
The second setting, Scale (calculate extent), is, for me, easier to visualize. The Scale setting acts
like a zoom: enter a smaller number (a small-scale map) and everything gets larger and you’ll see
less of your map. If you make the map box smaller, you’ll also see less of your map. Whereas with
Extent (calculate scale) you’ll always see the whole map, but the scale will change.
If the map has to be shifted within the map box, you can’t do that within Print Composer. Move
the map around in Map View, and when you return to Print Composer click on the Set Extent button
which forces the centre of the map box to be the same point as the centre of Map View.

Notes:

• Line width scale sets the width of lines (rivers, coastlines) in mm.
• If you are playing around with map boxes, you may end up with several of them. The only way to get
rid of them is to set their width and height to 0 and then click with the mouse.
EXPORTING AN IMAGE MEASURING DISTANCE
There are two ways of exporting an image. File > Save As Image will grab what To be able to measure distance in metres (or feet):
is on the screen, pixel for pixel, and dump that to a jpg or png file. If your Map
View window is set to a small size, say 750 x 580, that will be the pixel size of 1. Go to Settings > Project Properties > Projection, and choose Enable on the fly projection.
your image. To gain control over the image resolution you have to use the Export
as Image icon within Print Composer. These are the steps I suggest in obtaining the 2. Go to Settings > Project Properties > General and choose Meters (if you do this before
step 2, or as part of step 2, QGIS will override the meters setting and apply the degrees
best quality image from QGIS suitable for printing. For emailing or the web, Save
setting. You will end up with weird measurements like 471,792.87 degrees)
As Image is probably good enough.
3. Select the Measure Line icon, click anywhere on the map as a starting point, click
1. Decide how big the printed image is to be. Let us assume 8 x 10 inches (200 x 250 anywhere else as an end point and you should see the distance in kilometres. At the bottom
mm) and assume the map has already been set up in Map View ready to export. It is of the map you should see the position of the mouse (lat/long) as you move it around.
best to make the map in Map View cover a larger area than required. It can always
be cropped in Photoshop or similar program.
2. Open Print Composer and choose a Custom size paper slightly bigger than that
required for the print, say 220 x 270.
3. Set the resolution to at least 300 dpi, preferably 600.
4. Select the Add New Map icon and draw a box just inside the boundary of the map
box. Your map should appear inside the box you have just drawn.
5. For thin lines such as contour lines to appear thin, the Line width scale should be
set to something less than 0.2 (this dimension is in millimeters).
6. Choose the Export as Image icon, png format, and click OK. Note: You must add
the suffix ‘.png’ manually. If you don’t, the image won’t be created properly.
7. Edit the image in Photoshop (crop, resample and so on).

Note: For maps with thin lines, png is the preferred format because jpeg throws
a halo around thin lines.

Potrebbero piacerti anche