Introduction To Qgis

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Introduction To Qgis as PDF for free.

More details

  • Words: 3,747
  • Pages: 7
INTRODUCTION TO QGIS [email protected], April 2008

BACKGROUND This is an introduction to QGIS 0.9.1, a program that can manipulate geographical data and display the results on screen. It draws maps, in other words. The initials stand for Quantum Geographical Information System. GIS is the general term for these types of programs. QGIS can be downloaded free of charge (freeware) from this site. It is available for Mac, PC and other platforms. This introduction is written for the Mac, but the majority of it is applicable for PCs as well. QGIS is not the only freeware GIS program: •





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 the right software, such as OPENOSX GRASS). 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 to QGIS, though QGIS is more powerful – and more unstable (it has more bugs). TATUKGIS Free Viewer – PC only. And since I’m a Mac man, I can’t comment on it.

The power of these programs lies not in the ability to draw maps – most drawing 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, but I will be using only one type to demonstrate how QGIS works: ESRI shapefiles. Some government mapping agencies, such as Geoscience Australia, make this data freely available. Shapefiles are a type of data called vectors, a commonly used word in QGIS. A vector is a word that simply means you need at least two numbers to describe a certain item. Your speed when driving, for example, is not a vector because it only needs one number: 80 km/h. On the other hand, to locate the Sydney Opera house needs at least two: latitude and longitude; and three, if you want to know its height above sea level. To describe the shape of a coastline, a river, a lake, or the position of towns and mountains, requires lots of numbers. A shapefile is a long list of numbers (vectors) that tell QGIS how to draw features on a map.

Another type of map data is called raster data. Two examples are satellite images and aerial photographs. QGIS can import rasters. Instead of the shape of a river appearing on your map you will see an actual photo that aligns perfectly with the rest of the map. I will not be describing how to use raster data in this introduction, mainly because I don’t know how to do it. If anyone reading this knows the trick, please email me instructions, including sample data suitable for use with the map shown in these notes. But please check that it works with this map. Now, back to shapefiles. Three folders of shapefiles are included with this package: • • •

Coastline of Australia Rivers & Creeks State Boundaries

If you look inside the Coastline of Australia folder (the other two folders contain similar files), you will see four files typical of the shapefile format: • • • •

Coastline.dbf – a database that contains details (‘attributes’) of the features; Coastline.prj – describes the map projection; Coastline.shp – contains the shape of features (lakes, rivers, and so on); Coastline.shx – index file.

By using QGIS and the data in these folders, you will be able to draw a simple map of Australia if you follow these notes. The map will include state boundaries and a small number of rivers. One feature will be added at a certain latitude and longitude. Then the instrucitons will describe how to save the map to an image file so that it can be emailed or used inside a text document. I have tried to design these instructions so that anyone with a basic knowledge of computers but no knowledge of GIS, can draw a simple map. I hope that what took me four days – searching on the internet for programs and data, and scratching my head in front of my computer – will be reduced to an hour or so for anyone who works through these instructions. And I hope you will be surprised how easy it is. This is only an introduction. What you see here is my total knowledge of QGIS. 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? In my case – to draw maps to illustrate the routes of early explorers in Queensland. There is no quicker way to bore a reader than to reel off a list of place names, mountains and rivers. A simple uncluttered map has the power to bring a geographical story to life in a way that even a thousand words can’t do. I used QGIS to generate a base map of Queensland with all the features that I needed, then I selectively zoomed in or out and incorportated only those features I needed for a particular map. Basically, I drew one map and manipulated it to draw all the others, about 30 in total. The completed maps (see the PDF file Samples, included with this zip package) were not output directly from QGIS – it does not have the capability or flexibility to draw a finished map of the type I wanted. Rather, I used QGIS to generate the map features (mountains, rivers, towns) which I then used as a template. In other words, I spent a few minutes and traced over the top. My maps were simple enough to allow me to do that. In a few cases I did use the QGIS output, for example, when I wanted to use detailed contouring or a complicated river system as a background.

WHAT YOU NEED TO MAKE A MAP You will need QGIS from the QGIS website, and the shapefiles as described previously (Coastline of Australia, etc) which are included with this zip package. QGIS is a bit fussy about where the shapefiles are located. On the Mac, for instance, it can’t find files that are on external firewire drives (unless you have typed in /volumes in the File Name field). For this introduction I suggest you create a new folder called Mapping, and copy the shapefiles and QGIS to that folder. One more thing about location. QGIS calls making a map, a project, and it does not store the map data within your project. It remembers where the data came from and looks for it there every time you open the map. If you move the shapefiles somewhere else (because you don’t like them within the folder Mapping, for instance), or you rename the files, QGIS will ask you where they are, and you will have to tell QGIS where every single file is that you have moved. And that brings me to the first bug within QGIS 0.9.1 (assuming it has carried over from 0.9): 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; Legend - shows the layers from which you made the map; Overview – the red outline shows what proportion of the entire map data you are viewing.

The Map View window. This is your map area. Resize it with the little black dot on the left.

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 the layers that go to make up your at the bottom of this page. I won’t go map. A tick means a layer is being through them here. It is best to run your displayed. There will be nothing in this window when you first start. mouse over each toolbar icon at the top 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 it to the bottom by clicking and does. If the toolbar icons do not all fit 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 window at the right. I will indicate the use of a toolbar 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 You can change the color and thickness of the lines that make the map, and you can change the fill color, by double-clicking on the layer name, Coastline of Australia, in the Legend window. This will bring up a Layer Properties box (left). By double-clicking on the colored boxes (to the right of Outline color and Fill color) you can change the color. I suggest making both colors quite pale so that the layers to be added on top can be seen clearly. Many other options are available from the Layer Properties box. I will not go through them here, except to say that: •

under General you can change the name of the layer;



Metadata shows you the attributes of the layer. You won’t see many useful attributes for the coastline, but for other layers such as towns and rivers (not included with this introduction) the names of all the towns and rivers can be displayed on the map;



under Labels you can chose to show the names of towns and rivers if you have those particular layers added to the map (but only if the layers have names included as an attribute). To see how Labels works, tick the Display labels box (just underneath the box it should indicate that AREA will be displayed), click OK, and your map will be covered with AREA information. Now remove this unnecessary information by going back and unticking the Display Labels box.

Add the following layers by navigating to the indicated folder, then double clicking on it and selecting the appropriate shapefile from within. Remember, you have to navigate all the way until you see a gray shapefile ending with ‘.shp’ and then opening it. Only a shapefile will generate a new layer. •

State Boundaries - State Boundaries.shp



Rivers & Creeks - Barcoo River 2.5M.shp - Cooper Creek 2.5M.shp - Darling River 2.5M.shp - Flinders River 2.5M.shp - Thomson River 2.5M.shp - Towerhill Creek 2.5M.shp - Warrego River 2.5M.shp

Adding Your Own Features Here’s how to add a layer to indicate the camp of Duncan McIntyre when he camped on the Flinders River in March 1865. This new layer has just one point: Longitude 141.12ºE, Latitude 19.64ºS. The campsite will be added to a new layer so that I can turn it on and off independantly of other layers (I may not want it on all my maps). 1. To create a new layer do this: Layer > New Vector Layer, or you can just type ‘N’. The box shown below should appear.

After you have added each layer you can double click on its name and change the color and thickness. For example, you may want to make the state boundaries gray and the rivers blue. Once you have added these layers you will see why I want to use QGIS. Given that I am interested in mapping the routes of the early explorers in Australia, this simple mapmaking allows me to see how the explorers jumped from river to river to get from south to north: from the Darling, up the Warrego, Barcoo, Thomson, Towerhill Creek, and across the watershed to the Flinders. Plus, I can use this one map to generate all the different maps I require ( I would, of course, have added more features than those indicated) simply by zooming in or out if I want to show details of certain parts of their routes. I don’t have to draw a new map each time.

3. Click on OK again, and QGIS will present you with a Save As window. It is asking you: What do you want to call this new shapefile and where do you want to put it? For the File Name type in ‘Camp McIntyre’, then click Save. You have just created a blank shapefile into which we are going to enter the latitude and longitude. 4. To add a point to this new layer, click on the layer’s name to make it active, then click on the icon Toggle Editing (it looks like a pencil). This allows you to edit the layer. 5. Click on the next icon, Capture Point (again, it looks like a pencil). This icon is poorly named. It actually creates a new point on the layer. 6. Move the cursor into the Map View window. It should be shaped like a cross-hair. As you move it around, notice that the latitude and longitude are displayed on the lower right of the window. Move to the position 141.12, -19.64 (or any position you like). You may have to zoom in (use the magnifying icons on the toolbar) to be able to accurately set the position. 7. When you click to select the position, you will be asked to insert a value for the ‘Camp’ attribute you set up in Step 2. Type anything you like: ‘March 1865’, for instance. 8. To save the point you have just created, click on Toggle Editing to turn editing off, and you will be asked if you want to save. Click yes. 9. A symbol should appear at the point you selected on the map. This symbol can be changed to another type of symbol by double-clicking on the layer’s name in the Legend window and choosing a Symbol (from the many on offer) and Size.

You can continue to add as many features as you like to the new layer. 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 There are two ways of exporting an image. File > Save As Image will grab what 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 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 best quality image from QGIS suitable for printing. For emailing or the web, Save As Image is probably good enough. 1. Decide how big the printed image is to be. Let us assume 8 x 10 inches (200 x 250 mm) and assume the map has already been set up in Map View ready to export. It is 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.

MEASURING DISTANCE To be able to measure distance in metres (or feet): 1. Go to Settings > Project Properties > Projection, and choose Enable on the fly projection. 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 setting. You will end up with weird measurements like 471,792.87 degrees) 3. Select the Measure Line icon, click anywhere on the map as a starting point, click anywhere else as an end point and you should see the distance in kilometres. At the bottom of the map you should see the position of the mouse (lat/long) as you move it around.

Related Documents

Introduction To Qgis
June 2020 2
Qgis
August 2019 8
Qgis Notes.pptx
December 2019 3
Qgis Doc Faq
June 2020 3
Introduction To
November 2019 56
Qgis Doc Debutant
June 2020 5